^NyAw^
18th November 2011, 12:58
Hi,
I have class structures like this:
class classA
{
...
classA() //Constructor
{
foo();
}
virtual void foo()
{
//Do nothing
}
...
};
class classB : public classA
{
...
classB() : classA() //Constructor calls classA constructor
{
...
}
void foo()
{
//Specific code here
}
...
};
When I create an object of classB, it calls the constructor from classA.
The constructor of classA calls the method "foo()" that is redefined in the classB.
The problem is that "foo()" is executed from classA instead of classB.
Does anyone know how I must do this?
Thanks,
I have class structures like this:
class classA
{
...
classA() //Constructor
{
foo();
}
virtual void foo()
{
//Do nothing
}
...
};
class classB : public classA
{
...
classB() : classA() //Constructor calls classA constructor
{
...
}
void foo()
{
//Specific code here
}
...
};
When I create an object of classB, it calls the constructor from classA.
The constructor of classA calls the method "foo()" that is redefined in the classB.
The problem is that "foo()" is executed from classA instead of classB.
Does anyone know how I must do this?
Thanks,