Repository navigation
Expand file tree
/
Copy pathobject.cpp
More file actions
122 lines (111 loc) · 2.14 KB
/
Copy pathobject.cpp
File metadata and controls
122 lines (111 loc) · 2.14 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
// class time{
// int min;
// int hr;
// public:
// time(){}
// time(int m,int h){
// min=m;
// hr=h;
// }
// void display(void){
// cout<<min<<" "<<hr<<endl;
// }
// void sum(time *t1,time *t2){
// min=t1.min+t2.min;
// hr=min/60;
// min=min%60;
// hr=hr+t1.hr+t2.hr;
// }
// };
// int main(){
// int m,h;
// cin>>m>>h;
// time T1(m,h);
// cin>>m>>h;
// time T2(m,h);
// time T3;
// T3.sum(&T1,&T2);
// T1.display();
// T2.display();
// T3.display();
// }
//! important
// #include <iostream>
// using namespace std;
// class MyClass {
// public:
// int x;
// MyClass(int n) : x(n) {}
// };
// void func(MyClass obj) {
// obj.x++;
// cout << "Inside func: " << obj.x << endl;
// }
// int main() {
// MyClass obj(5);
// func(obj);
// cout << "Inside main: " << obj.x << endl;
// return 0;
// }
// //!important
// #include <iostream>
// using namespace std;
// class MyClass {
// public:
// int x;
// MyClass(int n) : x(n) {}
// };
// void func(MyClass obj) {
// obj.x++;
// cout << "Inside func: " << obj.x << endl;
// }
// int main() {
// MyClass obj(5);
// func(obj);
// cout << "Inside main: " << obj.x << endl;
// return 0;
// }
class matrix{
int m[3][3];
public:
void set(void){
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
cin>>m[i][j];
}
}
}
void display(void){
for(int i=0;i<3;i++){
cout<<endl;
for(int j=0;j<3;j++){
cout<<m[i][j]<<" ";
}
}
}
friend matrix trans(matrix mx);
};
matrix trans(matrix mx){
matrix n;
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
n.m[i][j]=mx.m[j][i];
}
}
return (n);
}
int main(){
matrix m1;
matrix m2;
m1.set();
m1.display();
m2=trans(m1);
m2.display();
}