#include <iostream>
using namespace std;
class vehicle {
int a;
public:
static int count_obj;
vehicle(int x) {
a=x;
count_obj++;
}
double disp() {
cout<<"\n"<<a;
}
};
class water_transport:public vehicle {
int a;
public:
water_transport(int x) {
a=x;
count_obj++;
}
double disp() {
cout<<"\n"<<a;
}
};
class road_transport {
int a;
public:
road_transport(int x) {
a=x;
count_obj++;
}
double disp() {
cout<<"\n"<<a;
}
};
class air_transport {
int a;
public:
air_transport(int x) {
a=x;
count_obj++;
}
double disp() {
cout<<"\n"<<a;
}
};
int vehicle::count_obj = 0;
int main(void) {
vehicle v(7);
v.disp();
water_transport w(13);
w.disp();
road_transport r(5);
r.disp();
air_transport a(5);
a.disp();
cout << "Total objects: " << vehicle::count_obj << endl;
return 0;
}
Comments
Leave a comment