How to make 3 classes in one .h file?

Here is the question.

Write THREE (3) classes in a file named hidden.h, where class footballer functions as a base class, while class divisionOne and class divisionTwo function as derived classes to class footballer.

I see no question here. All I see is a problem statement. Please state an actual question so that we can help you. This is a help forum.
You create a header file and the derived classes inside it?

There are 3 tables given. We must construct a header file named hidden.h.
......................................................
footballer (class)
# name : string
# club : string
#goals : int
# bonusSalary : double
____________________________
<<constructor>> +
footballer(n : string, c : string, g : int)
+
salary()
.......................................................

......................................................................
___________________________________
divisionOne
<<constructor>> +
divisionOne(n : string, c : string, g : double) -
salary()
.....................................................................

.....................................................................
___________________________________
divisionTwo
<<constructor>> +
divisionTwo(n : string, c : string, g : double) -
salary()
.......................................................................

Write THREE (3) classes in a file named hidden.h, where class footballer functions as a base class, while class divisionOne and class divisionTwo function as derived classes to class footballer.
Last edited on
You create a class like this:

1
2
3
4
5
6
7
8
9
10
11
12
class Xyz {
  // everything is private here (optionally you may use the key word private
  // ...
  
  public:
  // everything is public here.
  // ...

  protected:
  // everything is protected here
  // ...
};



You inherit like this:
1
2
3
class Xy : public Xyz {
  // same as above
};



If you need to use polymorphism, you may want to read about virtual as well.
Thank you. It helps me. I will post my coding once i done it.
Is this correct?

#include <iostream>
#include <string>
using namespace std;

class footballer
{
public:
string name;
string club;
int goals;
double bonusSalary;
private:
footballer(string n, string c, double g);
double salary();
};
class divisionOne : public footballer
{
public:
divisionOne(string n, string c, double g);
double salary();
};
class divisionTwo
{
divisionOne(string n, string c, double g);
double salary();
};

Your divisionTwo class doesn't have a base class? Think
Topic archived. No new replies allowed.