Question about the Factory pattern.
Hallo, I am working on an assignment where we get extras points for using design patters. I have no real experience with design patters and I am not that experienced with programming, so I have a question about the factory patter.
Is this correct use of the factory pattern?
Code:
class Object
{
public:
// List of virtual functions
protected:
Object();
};
class ObjectA : public Object
{
public:
ObjectA()
// List of private functions
};
class ObjectB : public Object
{
public:
ObjectB()
// List of private functions
};
class ObjectFactory
{
public:
ObjectFactory();
ObjectA* createObjectA()
{
ObjectA* obj = new ObjectA();
return obj;
}
ObjectB* createObjectB();
};
Thanks