/*
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world!" << endl;
return 0;
}
*/
/*
#include<iostream>
#include<string>
using namespace std;
class Point{
int x, y;
public:
Point(int x, int y) {this->x = x; this-> y = y;}
int getX() {return x;}
int getY() {return y;}
protected:
void move(int x, int y) {this->x = x; this-> y = y;}
};
class ColorPoint : public Point{
string color;
public:
ColorPoint(int x, int y, string color) : Point(x, y)
{
this-> color = color;
}
void setPoint(int x, int y)
{
move(x,y);
}
void setColor(string color)
{
this->color = color;
}
void show()
{
cout << color << "색으로 " << "(" << getX() << "," << getY() << ")" << "에 위치한 점입니다." << endl;
}
};
int main()
{
ColorPoint cp(5, 5, "RED");
cp.setPoint(10, 20);
cp.setColor("BLUE");
cp.show();
}
*/
/*
#include<iostream>
#include<string>
using namespace std;
class Point{
int x,y;
public:
Point(int x, int y) {this->x = x; this->y = y;}
int getX() {return x;}
int getY() {return y;}
protected:
void move(int x, int y) {this->x = x; this->y = y;}
};
class ColorPoint : Point{
string color;
public:
ColorPoint(int x=0, int y=0, string color="BLACK") : Point(x, y)
{
this->color = color;
}
void setPoint(int x, int y)
{
move(x, y);
}
void setColor(string color)
{
this->color = color;
}
void show()
{
cout << color << "색으로 " << "(" << getX() << "," << getY() << ")에 위치한 점입니다." << endl;
}
};
int main()
{
ColorPoint zeroPoint;
zeroPoint.show();
ColorPoint cp(5, 5);
cp.setPoint(10, 20);
cp.setColor("BLUE");
cp.show();
}
*/
/*
#include<iostream>
using namespace std;
class BaseArray{
private:
int capacity;
int *mem;
protected:
BaseArray(int capacity=100)
{
this->capacity = capacity;
mem = new int [capacity];
}
~BaseArray() {delete [] mem;}
void put(int index, int val) {mem[index] = val; }
int get(int index) {return mem[index]; }
int getCapacity() {return capacity; }
};
class MyQueue : public BaseArray{
int x=-1,y=-1;
public:
MyQueue(int a) : BaseArray(a) {}
void enqueue(int n)
{
y++;
put(y,n);
}
int dequeue()
{
x++;
return get(x);
}
int capacity()
{
return getCapacity();
}
int length()
{
return y-x;
}
};
int main()
{
MyQueue mq(100);
int n;
cout << "큐에 삽입할 5개의 정수를 입력하라>> ";
for(int i=0; i<5;i++)
{
cin >> n;
mq.enqueue(n);
}
cout << "큐의 용량: " << mq.capacity() << ", 큐의 크기: " << mq.length() << endl;
cout << "큐의 원소를 순서대로 제거하여 출력한다>> ";
while(mq.length() != 0)
{
cout << mq.dequeue() << " ";
}
cout << endl << "큐의 현재크기: " << mq.length() << endl;
}
*/
/*
#include<iostream>
using namespace std;
class BaseArray{
private:
int capacity;
int *mem;
protected:
BaseArray(int capacity=100)
{
this->capacity = capacity;
mem = new int [capacity];
}
~BaseArray() {delete [] mem;}
void put(int index, int val) {mem[index] = val; }
int get(int index) {return mem[index]; }
int getCapacity() {return capacity; }
};
class MyStack : public BaseArray{
int x=-1;
public:
MyStack(int a) : BaseArray(a) {}
void push(int n)
{
x++;
put(x, n);
}
int pop()
{
return get(x--);
}
int capacity()
{
return getCapacity();
}
int length()
{
return x+1;
}
};
int main()
{
MyStack mstack(100);
int n;
cout << "스택에 삽입할 5개의 정수를 입력하라>> ";
for(int i=0;i<5;i++)
{
cin >> n;
mstack.push(n);
}
cout << "스택용량: " << mstack.capacity() << ", 스택크기: " << mstack.length() << endl;
cout << "스택의 모든 원소를 팝하여 출력한다>> ";
while(mstack.length() != 0)
{
cout << mstack.pop() << " ";
}
cout << endl << "스택의 현재크기: " << mstack.length() << endl;
}
*/
/*
#include<iostream>
using namespace std;
class BaseMemory{
char *mem;
protected:
BaseMemory(int size) {mem = new char[size]; }
};
class ROM : public BaseMemory{
public:
ROM(int memo, )
};
*/
/*
#include<iostream>
using namespace std;
class Base{
public:
void f() { cout << "Base::f() called " << endl; }
};
class Derived : public Base{
public:
void f() {cout << "Derived::f() called" << endl; }
};
int main()
{
Derived d, *pDer;
pDer = &d;
pDer->f();
Base* pBase;
pBase = pDer;
pBase->f();
}
*/
#include<iostream>
using namespace std;
class Base{
public:
virtual void f() { cout << "Base::f() called" << endl;}
};
class Derived : public Base{
public:
virtual void f() {cout << "Derived::f() called" << endl;}
};
int main()
{
Derived *pDer, d;
pDer = &d;
pDer->f();
Base* pBase;
pBase = pDer;
pBase ->f();
}