Is this a good code (came across while reading code of a colleague)
- by eriks
// file a.hpp
class a;
typedef boost::shared_ptr<a> aPtr
class a{
public:
static aPtr CreateImp();
virtual void Foo() = 0 ;
....
};
//file aImp.hpp
class aImp : public a{
virtual void Foo();
};
//file aImp.cpp
aPtr a::CreateImp()
{
return aPtr(new aImp());
}
void aImp::Foo(){}
The client must use CreateImp to get ptr to 'a', and can't use 'a' other ways.
What do you think about this implementation?
what do you think about this king of implementation?