Jan 27, 2011 at 9:44am Jan 27, 2011 at 9:44am UTC
Yes, sorry...I forgot the 'public' keywork in the example...but, of course, in my code I put it!
Daniele.
Jan 27, 2011 at 10:14am Jan 27, 2011 at 10:14am UTC
It all depends on where you want the creator to go. But let's assume that you want one in each concrete class and not the interface, then CMyObj.cpp should be:
1 2 3 4 5 6 7
#include "CMyObj.h"
int CMyObj::Method1()
{ ... }
IMyObj* CMyObj:: CreateMyObj()
{ return new MyObj(); }
IMyObj.h should have:
1 2 3 4 5
class IMyObj
{
public :
virtual int Method1() = 0;
};
And CMyObj.h remains unchanged.
Last edited on Jan 27, 2011 at 10:17am Jan 27, 2011 at 10:17am UTC