📄 main.cpp
字号:
#include <iostream>
#include <stdlib.h>
#include <string>
using namespace std;
class Cat {
public:
string name;
};
class Dog {
public:
string name;
};
class Human {
public:
string name;
};
class Door {
private:
int HowManyInside;
public:
void Start();
void GoThrough(Cat *acat);
void GoThrough(Dog *adog);
void GoThrough(Human *ahuman);
};
void Door::Start() {
HowManyInside = 0;
}
void Door::GoThrough(Cat *somebody) {
cout << "Welcome, " << somebody->name << endl;
cout << "A cat just entered!" << endl;
HowManyInside++;
}
void Door::GoThrough(Dog *somebody) {
cout << "Welcome, " << somebody->name << endl;
cout << "A dog just entered!" << endl;
HowManyInside++;
}
void Door::GoThrough(Human *somebody) {
cout << "Welcome, " << somebody->name << endl;
cout << "A human just entered!" << endl;
HowManyInside++;
}
int main(int argc, char *argv[])
{
Door entrance;
entrance.Start();
Cat *SneekyGirl = new Cat;
SneekyGirl->name = "Sneeky Girl";
Dog *LittleGeorge = new Dog;
LittleGeorge->name = "Little George";
Human *me = new Human;
me->name = "Jeff";
entrance.GoThrough(SneekyGirl);
entrance.GoThrough(LittleGeorge);
entrance.GoThrough(me);
delete SneekyGirl;
delete LittleGeorge;
delete me;
system("PAUSE");
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -