/*
#include <iostream>
#include <cstring>
using namespace std;
class Person{
char* name;
int id;
public:
Person(int id, const char* name);
Person(const Person& person);
~Person();
void changeName(const char *name);
void show() { cout << id << ',' << name << endl; }
};
Person::Person(int id, const char* name){
this->id = id;
int len = strlen(name);
this->name = new char [len+1];
strcpy(this->name, name);
}
Person::Person(const Person& person){
this->id = person.id;
int len = strlen(person.name);
this->name = new char [len+1];
strcpy(this->name, person.name);
cout << "복사 생성자 실행. 원본 객체의 이름 " << this->name << endl;
}
Person::~Person(){
if(name)
delete [] name;
}
void Person::changeName(const char* name){
if(strlen(name) > strlen(name))
return;
strcpy(this->name, name);
}
void f(Person person){
person.changeName("dummy");
}
Person g(){
Person mother(2, "Jane");
return mother;
}
int main()
{
Person father(1, "Kitae");
Person daughter(father);
cout << "daughter 객체 생성 직후 ----" << endl;
father.show();
daughter.show();
daughter.changeName("Grace");
cout << "daughter 이름을 Grace로 변경한 후 ----" << endl;
father.show();
daughter.show();
Person son = father; //복사 생성자 호출
f(father); //복사 생성자 호출
g(); //복사 생성자 호출
return 0;
}
*/
/*
#include <iostream>
using namespace std;
class Circle {
int radius;
public:
Circle() { radius = 1; }
Circle(int radius) { this->radius = radius; }
void setRadius(int radius) { this->radius = radius; }
double getArea() { return 3.14*radius*radius; }
};
void swap(Circle &A, Circle &B){
Circle tmp;
tmp = A;
A = B;
B = tmp;
}
int main(){
Circle circle10(10);
Circle circle20(20);
cout << "circle10 : " << circle10.getArea() << ", circle20 : " << circle20.getArea() << endl;
swap(circle10, circle20);
cout << "swap 후" << endl;
cout << "circle10 : " << circle10.getArea() << ", circle20 : " << circle20.getArea() << endl;
}
*/
/*
#include <iostream>
using namespace std;
void half(double &n){
n *= 0.5;
}
int main(){
double n=20;
half(n);
cout << n;
}
*/
/*
#include <iostream>
using namespace std;
void combine(string &text1, string &text2, string &text3){
text3 = text1 + ' ' + text2;
}
int main(){
string text1("I love you"), text2("very much");
string text3;
combine(text1, text2, text3);
cout << text3;
}
*/
/*
#include <iostream>
using namespace std;
bool bigger(int a, int b, int& big);
bool bigger(int a, int b, int& big){
if(a==b) {return true;}
else
{
big = a>b?a:b;
return false;
}
}
int main(){
int a, b, big;
cout << "a : ";
cin >> a;
cout << "b : ";
cin >> b;
bigger(a, b, big);
cout << big << endl;
}
*/
/*
#include <iostream>
using namespace std;
class Circle{
int radius;
public:
Circle(int r) {radius=r;}
int getRadius() { return radius; }
void setRadius(int r) { radius = r; }
void show() { cout << "반지름이 " << radius << "인 원" << endl; }
};
void increaseBy(Circle &a, Circle b){
int r = a.getRadius() + b.getRadius();
a.setRadius(r);
}
int main(){
Circle x(10), y(5);
increaseBy(x, y);
x.show();
}
*/
/*
#include <iostream>
#include <cstring>
using namespace std;
char& find(char a[], char c, bool& success);
int main() {
char s[] = "Mike";
bool b = false;
char& loc = find(s, 'M', b);
if(b == false){
cout << "M을 발견할 수 없다" << endl;
return 0;
}
loc = 'm';
cout << s << endl;
}
char& find(char a[], char c, bool& success){
for(int i=0 ; i<strlen(a) ; i++){
if(a[i]==c){
success = true;
return a[i];
}
}
}
*/
/*
#include <iostream>
using namespace std;
class MyIntStack{
int p[10];
int tos;
public:
MyIntStack();
bool push(int n);
bool pop(int &n);
};
MyIntStack::MyIntStack(){
this->tos = 0;
}
bool MyIntStack::push(int n){
if(tos==10){return false;}
p[tos] = n;
tos++;
return true;
}
bool MyIntStack::pop(int &n){
if(tos==0){return false;}
n = p[--tos];
return true;
}
int main(){
MyIntStack a;
for(int i=0; i<11; i++){
if(a.push(i)) cout << i << ' ';
else cout << endl << i+1 << " 번째 stack full" << endl;
}
int n;
for(int i=0; i<11; i++){
if(a.pop(n)) cout << n << ' ';
else cout << endl << i+1 << " 번째 stack empty";
}
cout << endl;
}
*/