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