error 2039 {dtor} is not element of ImyInterface - when does this happen?
-
I have declared a simpl interface using
__interface ImyInterface
{
virtual Method1() abstract;
virtual Method2() abstract;
};
class MyClass : public ImyInterface, public CBase
{
public:
MyClass();
virtual ~MyClass();
virtual Method1();
virtual Method2();protected:
int member1, member2;
};This is implemented in big code where I use downcasts like
CBase* ptr = new CMyClass();
dynamic_cast(ptr);and some other typecasting of ImyInterface* found only by "search complete project" on one hand destructors are not allowed in an Interface because __interface uses __declspec(novtable) on the other hand the compiler wants to have a destructor (error is shown at "}" of the derived class) What constructs in the code will force the compile to raise this error, and, is the usage of __interface in c++ too special for interfaces and I should use struct only?. In common: when never use interface as a base of a class?
-
I have declared a simpl interface using
__interface ImyInterface
{
virtual Method1() abstract;
virtual Method2() abstract;
};
class MyClass : public ImyInterface, public CBase
{
public:
MyClass();
virtual ~MyClass();
virtual Method1();
virtual Method2();protected:
int member1, member2;
};This is implemented in big code where I use downcasts like
CBase* ptr = new CMyClass();
dynamic_cast(ptr);and some other typecasting of ImyInterface* found only by "search complete project" on one hand destructors are not allowed in an Interface because __interface uses __declspec(novtable) on the other hand the compiler wants to have a destructor (error is shown at "}" of the derived class) What constructs in the code will force the compile to raise this error, and, is the usage of __interface in c++ too special for interfaces and I should use struct only?. In common: when never use interface as a base of a class?
found out the bugmyself now I used the virtual keyword in the declaration
class MyClass : virtual public ImyInterface, public CBase
removing the virtual keyword makes the error disappear :)