可以从类方法中知道对象实例名/变量名吗?例如:
#include <iostream>
using namespace std;
class Foo {
public:
void Print();
};
void Foo::Print() {
// what should be ????????? below ?
// cout << "Instance name = " << ?????????;
}
int main() {
Foo a, b;
a.Print();
b.Print();
return 0;
}
https://stackoverflow.com/questions/1795816
复制相似问题