what is the syntax for accessing address of this pointer in C++? -
i trying know address of pointer. tried in following way. can suggest me right method? trying print cout<<&this<<endl;
in class member function. compiler generates error c2102: '&' requires l-value.
if i'm not mistaken, std::cout << this
should suffice.
class foo { public: void foo() { std::cout << << std::endl; } }; int main() { foo foo{}; foo.foo(); }
Comments
Post a Comment