/*
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world!" << endl;
return 0;
}
*/
/*
#include<iostream>
using namespace std;
class Power{
int kick;
int punch;
public:
Power(int kick=0, int punch=0)
{
this->kick = kick;
this->punch = punch;
}
void show();
Power& operator++();
};
void Power::show()
{
cout << "kick=" << kick << ',' << "punch=" << punch << endl;
}
Power& Power::operator++()
{
kick++;
punch++;
return *this;
}
int main()
{
Power a(3,5),b;
a.show();
b.show();
b = ++a;
a.show();
b.show();
}
*/
/*
#include<iostream>
using namespace std;
class Power{
int kick;
int punch;
public:
Power(int kick=0, int punch=0)
{
this->kick = kick;
this->punch = punch;
}
void show();
bool operator!();
};
void Power::show()
{
cout << "kick=" << kick << ',' << "punch=" << punch << endl;
}
bool Power::operator!()
{
if(kick == 0 && punch == 0) return true;
else return false;
}
int main()
{
Power a(3,5),b(0,0);
if(!a) cout << "a의 파워가 0이다." << endl;
else cout<< "a의 파워가 0이 아니다." << endl;
if(!b) cout << "b의 파워가 0이다." << endl;
else cout << "b의 파워가 0이 아니다." << endl;
}
*/
/*
#include<iostream>
using namespace std;
class Power{
int kick;
int punch;
public:
Power(int kick=0, int punch=0)
{
this->kick = kick;
this->punch = punch;
}
void show();
Power operator++(int x);
};
void Power::show()
{
cout << "kick=" << kick << ',' << "punch=" << punch << endl;
}
Power Power::operator++(int x)
{
Power tmp = *this;
kick++;
punch++;
return tmp;
}
int main()
{
Power a(3,5),b;
a.show();
b.show();
b = a++;
a.show();
b.show();
}
*/
/*
#include<iostream>
using namespace std;
class Power{
int kick;
int punch;
public:
Power(int kick=0, int punch=0)
{
this->kick = kick;
this-> punch = punch;
}
void show();
friend Power operator+(int op1, Power op2);
};
void Power::show()
{
cout << "kick=" << kick << ',' << "punch=" << punch << endl;
}
Power operator+(int op1, Power op2)
{
Power tmp;
tmp.kick = op1 + op2.kick;
tmp.punch = op1 + op2.punch;
return tmp;
}
int main()
{
Power a(3,5),b;
a.show();
b.show();
b = 2 + a;
a.show();
b.show();
}
*/
/*
#include<iostream>
using namespace std;
class Power{
int kick;
int punch;
public:
Power(int kick=0, int punch=0)
{
this->kick = kick;
this->punch = punch;
}
void show();
friend Power operator+(Power op1, Power op2);
};
void Power::show()
{
cout << "kick=" << kick << ',' << "punch=" << punch << endl;
}
Power operator+(Power op1, Power op2)
{
Power tmp;
tmp.kick = op1.kick + op2.kick;
tmp.punch = op1.punch + op2. punch;
return tmp;
}
int main()
{
Power a(3,5),b(4,6),c;
a.show();
b.show();
c.show();
c = a + b;
a.show();
b.show();
c.show();
}
*/
/*
#include<iostream>
using namespace std;
class Power{
int kick;
int punch;
public:
Power(int kick=0, int punch=0)
{
this->kick = kick;
this->punch = punch;
}
void show();
friend Power& operator++(Power op1);
friend Power operator++(Power op1, int x);
};
void Power::show()
{
cout << "kick=" << kick << ',' << "punch=" << punch << endl;
}
Power& operator++(Power& op1)
{
op1.kick++;
op1.punch++;
return op1;
}
Power operator++(Power& op1, int x)
{
Power tmp = op1;
op1.kick++;
op1.punch++;
return tmp;
}
int main()
{
Power a(3,5),b;
b = ++a;
a.show();
b.show();
b = a++;
a.show();
b.show();
}
*/
/*
#include<iostream>
using namespace std;
class Power{
int kick;
int punch;
public:
Power(int kick=0, int punch=0)
{
this->kick = kick;
this->punch = punch;
}
void show();
Power& operator<<(int n);
};
void Power::show()
{
cout << "kick=" << kick << ',' << "punch=" << punch << endl;
}
Power& Power::operator<<(int n)
{
kick+=n;
punch+=n;
return *this;
}
int main()
{
Power a(1,2);
a << 3 << 5 << 6;
a.show();
}
*/
/*
#include<iostream>
#include<string>
using namespace std;
class Book{
string title;
int price, pages;
public:
Book(string title="", int price=0, int pages=0)
{
this->title = title;
this->price = price;
this->pages = pages;
}
void show()
{
cout << title << ' ' << price << "원" << pages << "페이지" << endl;
}
string getTitle()
{
return title;
}
bool operator!();
};
bool Book::operator!()
{
if(price==0) return true;
}
int main()
{
Book
}
*/
/*
#include<iostream>
using namespace std;
class Color{
int red, green, blue;
public:
Color(int red=0, int green=0, int blue=0)
{
this->red = red;
this->green = green;
this->blue = blue;
}
void show();
Color operator+(Color op1);
bool operator==(Color op1);
};
void Color::show()
{
cout << red << " " << green << " " << blue << endl;
}
Color Color::operator+(Color op1)
{
Color tmp;
tmp.red = this->red + op1.red;
tmp.green = this->green + op1.green;
tmp.blue = this->blue + op1.blue;
return tmp;
}
bool Color::operator==(Color op1)
{
if(red==op1.red && green==op1.green && blue==op1.blue) return true;
else return false;
}
int main()
{
Color red(255, 0, 0), blue(0, 0, 255), c;
c = red + blue;
c.show();
Color fuchsia(255, 0, 255);
if(c == fuchsia) cout << "보라색 맞음"<< endl;
else cout << "보라색 아님" << endl;
}
*/
#include<iostream>
using namespace std;
class Matrix{
int a,b,c,d;
public:
Matrix(int a=0, int b=0, int c=0, int d=0)
{
this->a = a;
this->b = b;
this->c = c;
this->d = d;
}
void show();
Matrix& operator>>(Matrix op1);
Matrix& operator<<(Matrix op1);
};
void Matrix::show()
{
cout << "Matrix = " << '{' << a << b << c << d << '}' << endl;
}
Matrix& Matrix operator>>(int op1[])
{
op1.a = a;
op1.b = b;
op1.c = c;
op1.d = d;
return *this;
}
Matrix& Matrix::operator<<(int op1[])
{
a = op1.a;
b = op1.b;
c = op1.c;
d = op1.d;
return *this;
}
int main()
{
Matrix a(4,3,2,1),b;
int x[4], y[4] = {1,2,3,4};
a >> x;
b << y;
for(int i=0;i<4;i++)
{
cout << x[i] << ' ';
}
cout << endl;
b.show();
}