-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path50.cpp
More file actions
43 lines (38 loc) · 747 Bytes
/
50.cpp
File metadata and controls
43 lines (38 loc) · 747 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
//Polymorphism.
#include<iostream>
using namespace std;
class Employee
{
int ID;
float salary;
public:
void getdata(int a,int b)
{
ID=a;
salary=b;
}
void showdata()
{
cout<< "ID :: " <<ID<< "Salary :: " <<salary<< "\n";
}
};
class sample
{
public:
void display()
{
cout<< "Sample Class";
}
};
int main()
{
Employee obj[100];
Employee *eptr[10];
int a;
obj[0].getdata(1,10000); //Use dot Operator when there is an object at left hand side
obj[0].showdata();
eptr[0]=new Employee(); //This memory is at heap but eptr is at stack
eptr[0]->getdata(2,20000);
eptr[0]->showdata();
return 0;
}