test
This commit is contained in:
parent
37776af5db
commit
ab03d5f10c
4045 changed files with 286212 additions and 3 deletions
59
.config/Code/User/History/1591c2fd/HYmA.cpp
Normal file
59
.config/Code/User/History/1591c2fd/HYmA.cpp
Normal file
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
Rafay Ahmad
|
||||
23I-2526
|
||||
*/
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
class Complex{
|
||||
int real;
|
||||
int img;
|
||||
|
||||
public:
|
||||
|
||||
Complex(){}
|
||||
Complex(int real, int img) : real(real), img(img){}
|
||||
|
||||
int getReal(){
|
||||
return real;
|
||||
}
|
||||
|
||||
Complex operator+(Complex c){
|
||||
Complex res;
|
||||
res.real = real + c.real;
|
||||
res.img = img + c.img;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
friend ostream& operator<<(ostream&, Complex&);
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
int operator+(int a, Complex c){
|
||||
return a + c.getReal();
|
||||
}
|
||||
|
||||
ostream& operator<<(ostream& out, Complex& c){
|
||||
out<<c.real<<"+"<<c.img<<"i\n";
|
||||
return out;
|
||||
}
|
||||
|
||||
int main(){
|
||||
|
||||
Complex c1(1, 2);
|
||||
Complex c2(2, 3);
|
||||
Complex c4(2, 3);
|
||||
|
||||
Complex c3 = c1 + c2 + c4;
|
||||
// int c3 = c1 + c2 + c4;
|
||||
cout<<c3;
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue