Question about using interfaces and inheritance from CObject.
I have a question about how to use interfaces for a class which in addition is also derived from CObject. My english is not very well but I try to explain in detail.
I have a class termed CMyClass which should be derived from CObject in order to use run-time information and dynamic creation support via DECLARE_DYNCREATE and IMPLEMENT_DYNCREATE macros. In addition I want to introduce an interface via a struct termed IMyInterface which should expose only a couple of pure virtual methods to the user in order to hide implementation details of the class if an object is feed-in to any extern module or something like that. I know that C++ supports multiple inheritence but what is really better coding practice in this case.
1st approach: (using multiple inheritance)
----
struct IMyInterface
{
virtual void foo(void) = 0;
...
};
class CMyClass : public CObject, public IMyInterface
{
...
virtual void foo(void);
...
};
2nd approach: (using single inheritance)
----
struct IMyInterface : public CObject
{
virtual void foo(void) = 0;
...
};
class CMyClass : public IMyInterface
{
...
virtual void foo(void);
...
};
I have seen that for the 1st approach a declaration as follows seems to work:
class CMyClass : public CObject, public IMyInterface
But a declaration in the following way causes many problem with VS compiler:
class CMyClass : public IMyInterface, public CObject
For the 2nd approach, are there any weakness' if I sandwich the public abstract class (struct) IMyInterface between CObject and CMyClass?
Thank you very much in advance.

