You should create a child to A and add virtual methods if some code differ between A and its child
A.hh
class A : public class B {
// Common attributes and Functions
...
protected:
A(int ppvar) : B(ppvar) {}; // Not public
public:
A() : B(1) {};
virtual method(); // Method that differ between A and its Child
...
};
class A2 : public class A {
// Attributes only needed by A2
...
public:
A2() : A(2) {};
method(); // Say that A2 will use its own implementation of method
};
main.cc
int main(void)
{
bool PPVar = ...;
A *a;
if (PPVar)
a = new A();
else
a = new A2();
a->method();
return (0);
}
An abstract class A with two child AOn and Aoff also.