-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatic.cpp
More file actions
46 lines (40 loc) · 732 Bytes
/
static.cpp
File metadata and controls
46 lines (40 loc) · 732 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
#include<iostream>
using namespace std;
class Animal {
int age;
char type;
static int count;
public:
Animal() {
count++;
cout << "count " << count << endl;
}
void barks() {
cout << "animal barks." << endl;
}
~Animal() {
count--;
cout << "count " << count << endl;
}
void setCount(int c) {
this->count = c;
}
};
class hahaha {
private:
int a = 5;
public:
static int laugh;
static void hello() {
cout << "hello" << endl;
}
};
int Animal::count = 0;
int hahaha::laugh = 5;
int main() {
Animal o1, o2, o3;
o1.setCount(10);
cout << hahaha::laugh << endl;
hahaha::hello();
return 0;
}