S
Stephan Kurpjuweit
Hi,
could you please help me with the following example?
struct Base
{
virtual Base& operator = (const Base &k) {}
};
struct Derived: public Base
{
// 1
virtual Derived& operator = (const Derived &k) {}
// 2
virtual Base& operator = (const Base &k) {}
};
int main(int argc, char* argv[])
{
Derived *dp = new Derived();
Base *bp = new Derived(*dp);
*bp = *dp;
return 0;
}
Why does the assignment in main lead to a call to the second assignment
operator (// 2) and not to the first one (//1)?
Thank you,
Stephan
could you please help me with the following example?
struct Base
{
virtual Base& operator = (const Base &k) {}
};
struct Derived: public Base
{
// 1
virtual Derived& operator = (const Derived &k) {}
// 2
virtual Base& operator = (const Base &k) {}
};
int main(int argc, char* argv[])
{
Derived *dp = new Derived();
Base *bp = new Derived(*dp);
*bp = *dp;
return 0;
}
Why does the assignment in main lead to a call to the second assignment
operator (// 2) and not to the first one (//1)?
Thank you,
Stephan