I am new in C++. I don't know why we cant able to create Derived Class Reference.In derived class all the features of base will get in this case, then also why..Please help me with exact reason.If this is a duplicate one please share me the exact link.
#include<iostream>
using namespace std;
struct A
{
virtual void get()
{
cout<<"I am in Base"<<endl;
}
};
struct B:A
{
virtual void get()
{
cout<<"I am in Derived"<<endl;
}
};
int main()
{
B*ptr = new A(); // virtual.cpp:21: error: invalid conversion from A* to B*
ptr->get();
return 0;
}