I'm a little confused as to why this code compiles and runs:
class A { private: int* b; public: A() : b((int*)0xffffffff) {} int* get_b() const {return this->b;} }; int main() { A a; int *b = a.get_b(); cout<<std::hex<<b<<endl; return 0; } Output of running this code is FFFFFFFFas well... unexpected by me. Shouldn't this->b return const int* since it is in a const member function? and therefore the return line should generate a compiler-cast error for trying to cast const int* to int*
Obviously there's a gap here in my knowledge of what const member functions signify. I'd appreciate if someone could help me bridge that gap.