main.cpp
来自「C++ Source code from a tutorial」· C++ 代码 · 共 40 行
CPP
40 行
#include <iostream>
#include <stdlib.h>
#include <string>
using namespace std;
class Gobstopper {
public:
static string MyClassName() {
return "Gobstopper!";
}
int WhichGobstopper;
int Chew(string name) {
cout << WhichGobstopper << endl;
cout << name << endl;
return WhichGobstopper;
}
};
int main(int argc, char *argv[])
{
typedef int (Gobstopper::*GobMember)(string);
GobMember func = &Gobstopper::Chew;
Gobstopper inst;
inst.WhichGobstopper = 10;
Gobstopper another;
another.WhichGobstopper = 20;
(inst.*func)("Greg W.");
(another.*func)("Jennifer W.");
typedef string (*StaticMember)();
StaticMember staticfunc = &Gobstopper::MyClassName;
cout << staticfunc() << endl;
system("PAUSE");
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?