0
我正在寻找一种方式来打印这些实例的构造函数被调用,从构造函数中的变量的名称对象的名称:如何打印使用构造
#include <iostream>
struct A {
A() {
std::cout << "variable name = " /*magic here*/ << "\n";
}
};
int main() {
A abc; // should output "variable name = abc"
A def; // should output "variable name = def"
}
这是可能的如何?
背蜱被用于行代码,只使用4空间主导缩进的代码块。 – crashmstr
这个问题措辞很差。我们不知道你的意思。以代码形式提供您的意思。我们不知道'cout << [object]'是什么意思。 –
可能'cout << this;'? –