Why pA->foo() works in this code?
Hi
why this code works?
#include <iostream>
class A {
public:
void foo() {std::cout << "hi" << std::endl; };
};
void MakeA(A *pA) { pA = new A; }
int main() {
A* pA = NULL;
Make(pA);
pA->foo();
delete pA;
return 0;
}
And... why ((A*)NULL)->foo() works too?
Thanks in advance.
|