i am using vc++ compiler
Unhandled exception at 0x00000000 in project.exe: 0xC0000005: Access violation reading location 0x00000000.
this is the error i am getting
Code:
#include<iostream>
using namespace std;
class base
{
public:
virtual void paint()
{
cout<<"in middle\n";
}
};
class derived : public base
{
public:
void paint()
{
cout<<"in derived\n";
}
};
class middle
{
char str[10];
public :
derived *getinfo()
{
cout<<"which object you want\n";
cin>>str;
if (str == "derived")
{
return new(derived);
}
}
};
int main()
{
middle m;
base *b;
//derived *d;
derived d;
b = m.getinfo();
b->paint();
getchar();
return 0;
}
this is the error i am getting
Comment