-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFruitInheritance.cpp
More file actions
63 lines (50 loc) · 865 Bytes
/
FruitInheritance.cpp
File metadata and controls
63 lines (50 loc) · 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include<iostream>
using namespace std;
class Fruit
{
public:
static int fruitCounter;
Fruit()
{
fruitCounter++;
}
~Fruit()
{
fruitCounter--;
}
};
class Apples:public Fruit{
public:
static int appleCounter;
Apples()
{
appleCounter++;
}
~Apples()
{
appleCounter--;
}
};
class Mangoes:public Fruit{
public:
static int mangoCounter;
Mangoes()
{
mangoCounter++;
}
~Mangoes()
{
mangoCounter--;
}
};
int Fruit::fruitCounter=0;
int Apples::appleCounter=0;
int Mangoes::mangoCounter=0;
int main()
{
Apples first,second;
Mangoes fi,se;
cout<<"Total Number of Fruits="<<Fruit::fruitCounter<<endl;
cout<<"total number of apples="<<Apples::appleCounter<<endl;
cout<<"Total number of Mangoes="<<Mangoes::mangoCounter<<endl;
}