I usually program in C #, but try to do a bit of C ++ and try to implement interfaces in C ++ a bit.
In C #, I would do something like this:
class Base<T> { public void DoSomething(T value) { // Do something here } } interface IDoubleDoSomething { void DoSomething(double value); } class Foo : Base<double>, IDoubleDoSomething { }
In C ++, I implemented it as follows:
template <class T> class Base { public: virtual void DoSomething(T value) { // Do something here } }; class IDoubleDoSomething { public: virtual void DoSomething(double value) = 0; }; class Foo : public Base<double>, public IDoubleDoSomething { };
The problem is that I cannot create an instance of Foo because it is abstract (does not implement DoSomething). I understand that I can implement DoSomething and just call the method based on it, but I was hoping this was the best way to do this. I have other classes that inherit a database with different data types, and I have other classes that inherit from IDoubleDoSomething that don't use Base.
Any help was appreciated.
c ++ c # interface multiple-inheritance porting
Clueless
source share