Could a derived-class object treated as if it's the same type of a bases class? <noobieQ/>

Posted by M4design on Stack Overflow See other posts from Stack Overflow or by M4design
Published on 2010-05-22T09:36:04Z Indexed on 2010/05/22 9:40 UTC
Read the original article Hit count: 210

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 :)

© Stack Overflow or respective owner

Related posts about c++

Related posts about inheritance