What would be a good approach to implement a class in c++ like this:
Someclass.h:
class SomeClass
{
public:
SomeClass();
void kill();
}
Someclass.cpp:
SomeClass::kill(){
kill();//This would cause an infinit recursion
//How to fix it?
}
So what I'm trying to do is redeclare a function within my object as a method. I can't find if there is a namespace or something simular, that contains "kill()", "sleep(int sec)". Hope you can help.
SomeClass::kill(){
::kill();
}
::
accesses global scope
来源:https://stackoverflow.com/questions/25452566/c-use-default-functions-in-class-with-same-name