__FUNCTION__返回函数名的宏定义

   从当前运行的函数中得到函数名,使用__FUNCTION__ 及相关宏。

举例如下

#include <iostream>
#include <string>
using namespace std;
const char* hello()
{
    return __FUNCTION__;//返回函数名
}
const char*world()
{
    return __FUNCTION__;
}
int main()
{
    cout << hello() << endl << world() << endl;
    system("pause");
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/mathyk/p/12792579.html
今日推荐