c++ use default functions in class with same name

2019-03-04 06:30发布

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.

1条回答
对你真心纯属浪费
2楼-- · 2019-03-04 06:43
SomeClass::kill(){
    ::kill();
}

:: accesses global scope

查看更多
登录 后发表回答