Home > Net >  how to make a child and Parent class by the given information?
how to make a child and Parent class by the given information?

Time:02-02

I have been told to make a Satellite class, which is the parent class of the Moon and an artificial satellite. Extra information ( Satellites orbit planets, and Planets have zero or more Satellites). This is the only information that I was given. So I looked for a format for the parent and child classes. This was the result of what I found.

Format:

class Child: public Parent{};

By following this logic. Is this correct?

Class Moon: public satellites {

};

The given code above is what I came up with by following the format. However, I have a feeling that this doesn't seem right. Your guidance on this matter will be greatly appreciated.

CodePudding user response:

Your c in Class should be lowercase, and s in satellites should be uppercase.

class Moon: public Satellites{};

For more information about class rule in c you can read it here

CodePudding user response:

I have been told to make a Satellite class,

class Satellite{};

...which is the parent class of the Moon and an artificial satellite.

class Moon: public Satellite{};

class ArtificialSatellite: public Satellite{};
  • Related