It's said that in C++ constructor function, as long as the object has not finished construction, shouldn't call virtual function, or else there'll be "pure virtual function call error" thrown out. So I tried this:
#include<stdio.h>
class A{
virtual void f() = 0;
};
class A1 : public A{
public:
void f(){printf("virtual function");}
A1(){f();}
};
int main(int argc, char const *argv[]){
A1 a;
return 0;
}
compile it with g++ on windows, it works and prints
virtual function
So how to make my program throw out "pure virtual function call" exception?
Thanks!