Could someone tell me why does this code work while mA is null? See the output below. mA is null but invoking the write method works.
class A {
public:
void write();
};
void A::write() {
std::cout << "A::write()" << std::endl;
}
class B {
private:
A *mA;
public:
void writea();
};
void B::writea() {
std::cout << mA << std::endl;
std::cout << &(*mA) << std::endl;
(*mA).write();
}
int main()
{
B *b = new B();
b->writea();
delete b;
}
Output:
00000000
00000000
A::write()
Thanks in advance.