版权声明:本文为博主原创文章,如有需要,可以转载,但请注明出处。 https://blog.csdn.net/xunye_dream/article/details/84921610
直接上代码了。
#include <iostream>
using namespace std;
class ShowLog
{
public:
ShowLog()
{
cout << __func__ << ": Hello Kity" << endl;
print();
}
void print() const
{
cout << __func__ << ": I just doing something. HAHA" << endl;
}
~ShowLog()
{
cout << __func__ << ": Goodbye Kity" << endl;
}
};
static ShowLog showLog;
int main(int argc, char **argv)
{
cout << __func__ << ": Bingo, Good Idea" << endl;
return 0;
}
输出结果:
ShowLog: Hello Kity
print: I just doing something. HAHA
main: Bingo, Good Idea
~ShowLog: Goodbye Kity