In: Computer Science
1. write a class called football player with variables number, weight, height inside. Then make child classes for football player, one called defensive player, which will have sacks and interceptions as variables, and offensive player, which will have yards and fumbles as variables
INPUT CODE:

OUTPUT:

CODE TO COPY:
#include <iostream>
using namespace std;
class Football_Player{//PARENT CLASS
protected:
int number,weight,height;
public:
void setNumber(int x){//SETTING
DATA MEMBERS
number=x;
}
void getNumber(){
cout<<number;
}
};
class Defensive_Player : public Football_Player{//DERIVED
CLASS
int sacks,interceptions;
};
class Offensive_Player :public Football_Player{//DERIVED
CLASS
int yards,fumbles;
};
int main(){
Offensive_Player o1;//INTIALIZING OBJECT OF DERIVED CLASS
o1.setNumber(20);//USING DATA FUNCTION OF PARENT CLASS
o1.getNumber();
}