-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypeConversion2.cpp
More file actions
59 lines (50 loc) · 826 Bytes
/
Copy pathtypeConversion2.cpp
File metadata and controls
59 lines (50 loc) · 826 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
//type conversion class to class type
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
using namespace std;
class Product
{
private:
int a,b;
public:
void set(int x,int y)
{
a = x; b= y;
}
int getA()
{
return a;
}
int getB()
{
return b;
}
};
class item
{
private:
int x,y;
public:
void show()
{
cout<<" x = "<<x<<" y = "<<y<<endl;
}
item(){} //default constructor
item (Product p) //for assigning data int another class
{
x = p.getA();
y = p.getB();
}
};
int main(int argc, char const *argv[])
{
system("cls");
Product p1;
item Item;
p1.set(8,6);
Item = p1; //assigning data to another class
Item.show();
system("pause");
return 0;
}