When a class is instantiated, a virtual table pointer is created to point to its virtual table. And each virtual function is assigned a function address.
Will the pure virtual function be assigned a default function address?
class base {
public:
virtual void func() = 0;
};
class derived : public base {
public:
virtual void func() {
cout << "derived func" << endl;
}
};
int main()
{
base *ptr = new derived();
delete ptr;
ptr->func();
return 0;
}
I have run the demo on VS2017 and the error "performed a bad memory access" happened. I know that the "__cxa_pure_virtual" will be called under the Linux system. So how do I implement my "__cxa_pure_virtual"? And how can I assign the function address to my pure function?