C++将类名转字符串的方法

it2025-04-23  8

#include <iostream> #include <string> #define TRANS(name) #name class Demo { public: Demo() {} }; int main() { std::string str(TRANS(Demo)); std::cout << str << std::endl; return 0; }

输出"Demo"

最新回复(0)