-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path52.cpp
More file actions
38 lines (32 loc) · 695 Bytes
/
Copy path52.cpp
File metadata and controls
38 lines (32 loc) · 695 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
//WAP to show pointer to object.
#include<iostream>
using std::cout;
using std::cin;
class employee
{
private:
int id;
float salary;
public:
void getdata(int a,float b)
{
id=a;
salary=b;
}
void showdata()
{
cout<< "\nEmployee ID: " <<id<< "\nEmployee Salary: " <<salary;
}
};
int main()
{
//employee obj1;
//obj1.getdata(1,10000);
//obj1.showdata();
// The Above Block of Commented code does the same thing as the below code but below code uses pointers to object.
employee *eptr;
eptr = new employee();
eptr ->getdata(1,10000);
eptr ->showdata();
return 0;
}