TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: CHRISTOPHER BUTLER
from: CAMERON CLARK
date: 1997-07-31 16:45:00
subject: Re: C++ Confusion

CB> people could explain them to me (not so much what they do, but how 
hey're
CB> 3) deriving classes
    I can help on this one.
    Lets say you wanted an inheritence structure as the following.
    media--paper-magazine
         |    |---book
         |    |---news paper
         |
         |-electic--radio
                 |--TV
                 |--cable
    // base clasee "media"
    // all children will share the attributes of this class
    class media {
    private:
      // only media has access to this part
    protected:
      // only media and children can access this part
    public:
      // open to everyone
      void create();
      void send();
    }
    class paper : public media {
     // the public means that the protected and public data
     // of "media" can be accessed by "paper"
    }
    class book : public paper {}
    class magazine : public paper {}
    class news_paper : publis paper {}
    class electronic : public media {
    }
    class radio : public electronic {}
    class TV : public electronic {}
    class cable : public electronic {}
    
    
    This was meant to show how to declare a relationship among class types.
    You can now pass specific classes using generic parameters.
    void distributeMedia (media& m) {
       m.create();
       m.send()
    }
    This can be called using any media type (assuming create() and send()
    are attributes of the base clase "media")
    paper p;
    distributeMedia(p);
    TV tele;
    distributeMedia(TV);
--- GEcho 1.00
---------------
* Origin: Digital OnLine Magazine! - (409)838-8237 (1:3811/350)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.