我尝试了很多方法来解决这个问题,但是没有一个起作用。我想要达到的目标是这个。
我有这样的课。
class Auton {
public:
int slot;
const char * name;
void run();
};
Run Code Online (Sandbox Code Playgroud)
我要做的是使run函数执行不同的操作。例如 -
// The code below doesn't work, unfortunately :(
Auton one;
void one::run() {
// Do something here
}
Auton two;
void two::run() {
// Do something different here
}
Run Code Online (Sandbox Code Playgroud)
这可能吗?
c++ ×1