C++将类名转字符串

1、宏定义

#define STR_CLASS(var) #var

2、使用

class A;
cout<<STR_CLASS(A);

 

posted @ 2022-01-06 11:10  朱小勇  阅读(378)  评论(0编辑  收藏  举报