S
shintu
Hi,
For the following code snippet, the compiler complains for "mi *mi1=new
mi;" statement
//*******************************************************
#include <iostream>
using namespace std;
class base{
public :
virtual void f()=0;
virtual void g()=0;
};
class der1ublic base
{
public :
void f()
{
cout << " In Der1"<< endl;
}
};
class der2: public base
{
public:
void g()
{
cout << " In Der2"<< endl;
}
};
class mi : public der1,public der2
{
};
int main(int argc, char* argv[])
{
mi *mi1=new mi;
return 0;
}
//========================================
where as, it does not complain if the the base class is derived
virtually.
Please provide any explaination for this.
Thanks,
Sachin
For the following code snippet, the compiler complains for "mi *mi1=new
mi;" statement
//*******************************************************
#include <iostream>
using namespace std;
class base{
public :
virtual void f()=0;
virtual void g()=0;
};
class der1ublic base
{
public :
void f()
{
cout << " In Der1"<< endl;
}
};
class der2: public base
{
public:
void g()
{
cout << " In Der2"<< endl;
}
};
class mi : public der1,public der2
{
};
int main(int argc, char* argv[])
{
mi *mi1=new mi;
return 0;
}
//========================================
where as, it does not complain if the the base class is derived
virtually.
Please provide any explaination for this.
Thanks,
Sachin