forked from codebloded/BackToBasics.cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrowOpertaor.cpp
More file actions
35 lines (30 loc) · 750 Bytes
/
arrowOpertaor.cpp
File metadata and controls
35 lines (30 loc) · 750 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
#include<iostream>
using namespace std;
class Complex{
private:
int real;
int imaginary;
public:
void setData(int x , int y )
{
real =x;
imaginary = y;
}
void printData(void)
{
cout<<"The Real part of the complex numbers is "<< real<<endl;
cout<<"The imaginary part of the complex number is"<< imaginary<<endl;
}
};
int main()
{
Complex *ptr = new Complex;
//This is the arrow operator , this is used for dereferencing the pointer to get the value;
ptr->setData(23,4);
ptr->printData();
//Array of the objects
Complex *p = new Complex[2];
p->setData(4,5);
p->printData();
return 0;
}