forked from Haresh1204/Algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass.cpp
60 lines (56 loc) · 1.24 KB
/
class.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include<iostream>
using namespace std;
// Example 1 of Normal Class -
/*class Student{
public:
string name;
int id;
int age;
};
int main(){
Student s1,s2,s3;
s1.name="Sharib";
s1.id=14000;
s1.age=21;
s2.name="Shivam";
s2.id=14001;
s2.age=22;
s3.name="Shruti";
s3.id=14002;
s3.age=23;
cout<<"Details of student 1 : "<<"\n"<<"Name = "<<s1.name<<"\n"<<"Id = "<<s1.id<<"\n"<<"Age = "<<s1.age<<endl;
cout<<"Details of student 2 : "<<"\n"<<"Name = "<<s2.name<<"\n"<<"Id = "<<s2.id<<"\n"<<"Age = "<<s2.age<<endl;
cout<<"Details of student 3 : "<<"\n"<<"Name = "<<s3.name<<"\n"<<"Id = "<<s3.id<<"\n"<<"Age = "<<s3.age<<endl;
return 0;
}*/
// Example 2 of normal classes -
/*class rectangle{
public:
int Area(int a,int b){
return a*b;
}
};
int main(){
rectangle rec;
cout<<rec.Area(10,5)<<endl;
return 0;
}*/
// Example 3 of normal classes -
/*class Circle{
private:
int r;
public:
void setvalues(int);
float Area(){
return 3.14*r*r;
}
};
void Circle::setvalues(int x){
r=x;
}
int main(){
Circle crl;
crl.setvalues(5);
cout<<crl.Area()<<endl;
return 0;
}*/