B
Barzo
Hi,
I have a newbie doubt. In the following code, why BaseAImpl is
abstract? Deriving it from BaseImpl the IBase::foo() is not defined?
#include<iostream>
using namespace std;
class IBase
{
public:
virtual void foo() = 0;
};
class IBaseA : public IBase
{
public:
virtual void foo_bar_A() = 0;
};
class IBaseB : public IBase
{
public:
virtual void foo_bar_B() = 0;
};
class BaseImpl : IBase
{
public:
void foo(){cout << "BaseImpl::foo" << endl;};
};
class BaseAImpl : public IBaseA, public BaseImpl
{
public:
void foo_bar_A(){cout << "BaseAImpl::foo_bar_A" << endl;};
};
class BaseBImpl : public IBaseB, public BaseImpl
{
public:
void foo_bar_B(){cout << "BaseBImpl::foo_bar_B" << endl;};
};
int _tmain(int argc, _TCHAR* argv[])
{
IBaseA* A = new BaseAImpl;
A->foo_bar_A();
IBase* B = (IBase*)A;
B->foo();
delete A;
return 0;
}
I have a newbie doubt. In the following code, why BaseAImpl is
abstract? Deriving it from BaseImpl the IBase::foo() is not defined?
#include<iostream>
using namespace std;
class IBase
{
public:
virtual void foo() = 0;
};
class IBaseA : public IBase
{
public:
virtual void foo_bar_A() = 0;
};
class IBaseB : public IBase
{
public:
virtual void foo_bar_B() = 0;
};
class BaseImpl : IBase
{
public:
void foo(){cout << "BaseImpl::foo" << endl;};
};
class BaseAImpl : public IBaseA, public BaseImpl
{
public:
void foo_bar_A(){cout << "BaseAImpl::foo_bar_A" << endl;};
};
class BaseBImpl : public IBaseB, public BaseImpl
{
public:
void foo_bar_B(){cout << "BaseBImpl::foo_bar_B" << endl;};
};
int _tmain(int argc, _TCHAR* argv[])
{
IBaseA* A = new BaseAImpl;
A->foo_bar_A();
IBase* B = (IBase*)A;
B->foo();
delete A;
return 0;
}