-
Notifications
You must be signed in to change notification settings - Fork 0
/
static.cpp
43 lines (34 loc) · 841 Bytes
/
static.cpp
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
#include<iostream>
using namespace std;
class Student{
public:
static int noOfDepts;
static void setCount(int c){
count=c;
}
static int getCount(){
return count;
}
static string getUniversity(){
return university;
}
private:
static int count;
protected:
static string university;
};
int Student::noOfDepts=10;
int Student::count=5000;
string Student::university="IIT";
int main(){
Student st1;
Student st2;
cout<<"No. Of Depts "<<Student::noOfDepts<<" "<<endl;
cout<<"Count "<<Student::getCount()<<" "<<endl;
cout<<"University "<<Student::getUniversity()<<" "<<endl;
cout<<"Student-1 "<<st1.getCount()<<endl;
cout<<"Student-2 "<<st2.getCount()<<endl;
st1.setCount(6000);
cout<<"Student-1 after Change "<<st1.getCount()<<endl;
cout<<"Student-2 after Change "<<st2.getCount()<<endl;
}