-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass3.cpp
More file actions
42 lines (38 loc) · 707 Bytes
/
Copy pathclass3.cpp
File metadata and controls
42 lines (38 loc) · 707 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
//program to define st
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
class complex
{
private:
int a,b;
public:
complex addData(complex c)
{
complex result;
result.a = a+c.a;
result.b = b+c.b;
return result;
}
void setData(int x,int y)
{
a = x;
b = y;
}
void showdata()
{
cout<<" a = "<<a<<" b = "<<b<<endl;
}
};
int main(int argc, char const *argv[])
{
system("cls");
complex c1,c2,c3;
c1.setData(4,5); //taking data
c2.setData(3,8);//taking data
c3 = c1.addData(c2);
c3.showdata();
system("pause");
return 0;
}