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
}
...
};
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
}
...
};
To copy to clipboard, switch view to plain text mode
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,
Bookmarks