They both compile.
I do not understand why the method works even though the pointer is set to NULL. ...and then, the virtual one does not. (it crashes at run-time)
THE CODE:
#include "stdafx.h"
class Person {
public:
void PrintHello() {
printf("Hello \n\n");
}
~Person() {}
};
class Student {
public:
virtual void PrintHello() {
printf("hello");
}
virtual ~Student() {
}
};
int main() {
Person* p = NULL;
p->PrintHello();
Student* s = NULL;
s->PrintHello();
return 0;
}
... thanks a lot.