【C/C++开发笔记】C++将类名转字符串的方法

#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"

猜你喜欢

转载自blog.csdn.net/qq_37354286/article/details/109210670
今日推荐