(C++11) 預先定義的標識碼 __func__ 會隱含定義為字串,其中包含封入函式的不限定和未限定名稱。
__func__ 是由C++標準所授權,不是Microsoft延伸模組。
語法
__func__
傳回值
傳回包含函式名稱之字元的 Null 終止 const char 陣列。
範例
#include <string>
#include <iostream>
namespace Test
{
struct Foo
{
static void DoSomething(int i, std::string s)
{
std::cout << __func__ << std::endl; // Output: DoSomething
}
};
}
int main()
{
Test::Foo::DoSomething(42, "Hello");
return 0;
}
需求
C++11