Baffling behavior

Posted by sandeep on Stack Overflow See other posts from Stack Overflow or by sandeep
Published on 2010-03-20T13:53:20Z Indexed on 2010/03/20 14:01 UTC
Read the original article Hit count: 255

Filed under:
class A
{
 public:
 A()
 {

 }
};

class B : public  A
{
 public:
 B()
 {
 }
};

int main()
{
A *a=new A();
B * b=static_cast<B*>(a);
///The above code compiles while if I replace above two line in main with below assignment it gives error.
     A *a=new A();
    B * b=new A();

}

© Stack Overflow or respective owner

Related posts about c++