Is this a good code (came across while reading code of a colleague)
Posted
by eriks
on Stack Overflow
See other posts from Stack Overflow
or by eriks
Published on 2010-03-21T20:57:03Z
Indexed on
2010/03/21
21:01 UTC
Read the original article
Hit count: 420
c++
// 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?
© Stack Overflow or respective owner