#include <iostream>
using namespace std;
//结构体 按钮
struct UIButton{
int tag;
void touch(){
cout << "tag值为 " << tag << " 的Button被点击了" << endl;
}
};
//枚举 按钮的状态
enum ButtonType{
UP = 100,
DOWN,
LEFT,
RIGHT
};
//枚举 C++11 这样枚举里面的元素就可以和别的枚举一样名字了
enum class ButtonType2{
UP = 100,
DOWn,
LEFT,
RIGHT
};
//
void touchButton(UIButton sender){
sender.touch();
switch (sender.tag) {
case UP:
//
cout << "向上移动" << endl;
break;
case DOWN:
cout << "向下移动" << endl;
break;
case LEFT:
cout << "向左移动" << endl;
break;
case RIGHT:
cout << "向右移动" << endl;
break;
default:
break;
}
}
//主函数
int main(){
//创建结构体对象
UIButton button1;
button1.tag = UP;
UIButton button2;
button2.tag = DOWN;
UIButton button3;
button3.tag = LEFT;
UIButton button4;
button4.tag = RIGHT;
touchButton(button1);
// ButtonType2::UP;
int x = 100;
int y = 200;
if (x && y) {
cout << x << ' ' << y << endl;
}
return 0;
}