I try to find address of this
pointer, but this code is showing a strange
error:
#include <iostream>
using namespace std;
class Base
{
public:
void test()
{
void *address_of_this =&this;
cout<<address_of_this<<endl;
}
};
int main()
{ Base k;
k.test();
return 0;
} //error non-lvalue in unary'&'
Can you explain this error ?
Also point that what is illegal in taking address of this
?