CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Threaded View

  1. #1
    Join Date
    Mar 2006
    Location
    Inida
    Posts
    119

    Post why can not we assign base class object reference to derived class pointer?

    class Base
    {
    public:
    Base(int ii = 0 , char cc = 65) : i(ii) , c(cc) {}
    int i;
    char c;
    };

    class Derived
    {
    public:
    Derived(int ii = 0 , char cc = 65 , int id = 10 , char cd = 66) : Base(ii , cc) , i(id) , c(cd) {}
    int i;
    char c;
    };

    void main()
    {
    Base bo;
    Derived *dp = &bo;
    }
    Last edited by adapanaidu; May 10th, 2006 at 05:02 AM. Reason: question is wrong.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured