Create a class called Student; this class is inherited from the Subject class.
This class must have the following data members:
A student number, for example “200605544”.A character member for storing a student gender, for example ‘M’ for male and ‘F’ for female
This class must have the following methods:
A public default constructor that sets data members to appropriate default values.A setStudent method that provides the relevant data members with valid
supplied values. Ensure that a student number is not an empty string and that
only M/mF/f are supplied for gender.A method called getStudNum that returns a student number.A method called getGender that returns a student’s gender, for example
“Female”.An overloaded + operator that will accumulate the year marks of two or more students An overloaded > operator that checks if one student’s year mark is greater than
another students’ An overloaded == that checks a student’s subject code against a given value
#include<iostream>
using namespace std;
class A
{
public:
A() { cout << "A's constructor called" << endl; }
};
class B
{
public:
B() { cout << "B's constructor called" << endl; }
};
class C: public B, public A // Note the order
{
public:
C() { cout << "C's constructor called" << endl; }
};
int main()
{
C c;
return 0;
}
Comments
Leave a comment