-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCH01_P02_ClassMember_ClassMethod.cpp
More file actions
66 lines (53 loc) · 970 Bytes
/
Copy pathCH01_P02_ClassMember_ClassMethod.cpp
File metadata and controls
66 lines (53 loc) · 970 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
64
65
66
/**
* class = variable[data Member] + function[method]
* */
#include<iostream>
#include<string>
using namespace std;
/**
* data member : private
* method : public
* */
/**
* Abstraction means displaying only essential information and hiding the details
*
* */
class Result
{
int rollno;
string name;
float marks;
bool status;
public:
void setData() // to get info from user
{
cout<<"Enter rollno : ";
cin>>rollno;
cout<<"Enter name : ";
cin>>name;
cout<<"Enter marks : ";
cin>>marks;
if(marks > 33)
status = 1;//pass
else
status = 0;//fail
}
void getData()
{
cout<<"rollno : "<<rollno<<endl;
cout<<" name : "<<name<<endl;
cout<<" marks : "<<marks<<endl;
cout<<"status : "<<status<<endl;
if(status)
cout<<"pass....";
else
cout<<"fail....";
}
};
int main()
{
Result r; // object 'r'
r.setData(); //method
r.getData(); //method
// cout<<"rollno : "<<r.rollno<<endl;
}