🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c++.moderated
Article #56

Simple inheritance Q

#56
From: Eric Simon
Date: Tue, 27 Feb 1996 10:34
37 lines
1542 bytes
I have a base class, called Animal, and a derived class, called Cat.

In my main program I have:

1.    Animal *p;
2.    Cat a(args);
3.    p = &a;

Now, if I define
    class Cat:Animal{...

then I get the error in line 3:
  Can not convert Cat * to Animal *

But if I define
   class Cat:public Animal{...

everything is fine.

Can anyone tell me why?

Thanks,

Eric

+-----------------------------------------------------------------+
| Eric Simon     | erics@access.digex.net                         |
| ULTIMATE!      | http://www.access.digex.net/~erics/home.html   |
+-----------------------------------------------------------------+
| proud daddy to Joshua (4/18/93) and Eliana (3/12/95)            |
+-----------------------------------------------------------------+


      [ Articles to moderate: mailto:c++-submit@netlab.cs.rpi.edu ]
      [  Read the C++ FAQ: http://www.connobj.com/cpp/cppfaq.htm  ]
      [  Moderation policy: http://www.connobj.com/cpp/guide.htm  ]
      [      Comments? mailto:c++-request@netlab.cs.rpi.edu       ]
Technical Details
Message-ID: <4gumo0$hta@netlab.cs.rpi.edu>
Path: arc1-ca.pugleaf.net!library.erc.clarkson.edu!rpi!not-for-mail

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!library.erc.clarkson.edu!rpi!not-for-mail
From: erics@access2.digex.net (Eric Simon)
Newsgroups: comp.lang.c++.moderated,comp.lang.c++
Subject: Simple inheritance Q
Date: 27 Feb 1996 10:34:40 -0000
Organization: UPA (a/k/a Joshua's daddy)
Sender: cppmods@netlab.cs.rpi.edu
Approved: devitto@ferndown.ate.slb.com
Message-ID: <4gumo0$hta@netlab.cs.rpi.edu>
NNTP-Posting-Host: netlab.cs.rpi.edu
X-Original-Date: 26 Feb 1996 17:16:07 GMT