CPP 게임 실습
#include <iostream>
using namespace std;
class Game
{
public:
virtual void start(){};
};
class BaseBall : public Game
{
public:
void start(){
cout << "BaseBall Start!!" << endl;
};
};
class UpDown : public Game
{
public:
void start(){
cout << "UpDown Start!!" << endl;
};
};
void main()
{
Game* game[2];
BaseBall baseball;
UpDown updown;
game[0] = &baseball;
game[1] = &updown;
int mode;
cout << "====================" << endl;
cout << "=1. BaseBall =======" << endl;
cout << "====================" << endl;
cout << "=2. UpDown==========" << endl;
cout << "====================" << endl;
cout << "input:" ;
cin >> mode;
system("cls");
if( mode == 1 )
{
cout << "====================" << endl;
cout << "=1. BaseBall =======" << endl;
cout << "====================" << endl;
game[0]->start();
}
else if( mode == 2 )
{
cout << "====================" << endl;
cout << "=2. UpDown==========" << endl;
cout << "====================" << endl;
game[1]->start();
}
}
'실습과제 모음' 카테고리의 다른 글
[JAVA1] 2012-10-14 실습 #1 (0) | 2012.10.14 |
---|---|
CPP 실습 (0) | 2012.09.22 |
C언어 실습문제 0811 (0) | 2012.08.11 |
JAVA Mysql + JTable + File (0) | 2012.07.29 |
JAVA JFrame + MySql 추가 실습예제 (0) | 2012.07.28 |