16,472
社区成员
发帖
与我相关
我的任务
分享
class CTest
{
public:
CTest() { m_val = 0; } // 类初始化赋值
~CTest() {}
// 这个函数就是返回变量值, 顺便打印出在哪个函数哪个文件被使用
int GetValue(const char *func, const char *file, int line)
{
printf("used at [%s] in [%s(%d)]\n", func, file, line);
return m_val;
}
protected:
int m_val; // 我就当它是你要找的变量了
};
// 实例化类
CTest m_test;
// 关键的地方, xxxx 替换成你原来变量的名字
#define xxxx m_test.GetValue(__FUNCTION__, __FILE__, __LINE__)