Why does this code work, when pointer is not pointed to any object? Output- It is calling show_base() without even pointing to any object.
#include<iostream>
using namespace std;
class base
{
public:
void show_base()
{
cout<<" It is a base class"<<endl;
}
};
class derived: public base
{
public:
void show_derived()
{
cout<<" It is derived class"<<endl;
}
};
int main()
{
base *ptr=NULL;
ptr->show_base();
}