Say I got:
class X_
{
public:
void do() { }
}
class Y_ : public X_
{
}
And I have this function:
void foo(X_ whatever)
{
whatever.do();
}
Can I send a “Y_” object to the foo function, would this work?
I just realized that I could have tested this myself 🙂
Yes, but it will get sliced – all the Y_ parts of the object will be chopped off, and it will become an X_. You normally need to pass by reference in this situation, as normally do() will be a virtual function:
BTW, I don’t know what you think those suffixed underscores are gaining you, but I would have said “nothing”.