A
Alf P. Steinbach
#include <iostream>
struct Belcher
{
int x;
void belch() { std::cout << x << std::endl; }
Belcher( int anX ): x( anX ) {}
};
struct Person: private Belcher { Person(): Belcher( 666 ) {} };
struct Viking: Person
{
void eat() {}
void dine( bool belch )
{
eat();
if( belch )
{
Viking* pv = this;
::Belcher* p = :Belcher*) pv;
// Why is qualification necessary here?
}
}
};
int main()
{
Viking v;
Viking* pv = &v;
Belcher* p = (Belcher*) pv;
p->belch();
}
struct Belcher
{
int x;
void belch() { std::cout << x << std::endl; }
Belcher( int anX ): x( anX ) {}
};
struct Person: private Belcher { Person(): Belcher( 666 ) {} };
struct Viking: Person
{
void eat() {}
void dine( bool belch )
{
eat();
if( belch )
{
Viking* pv = this;
::Belcher* p = :Belcher*) pv;
// Why is qualification necessary here?
}
}
};
int main()
{
Viking v;
Viking* pv = &v;
Belcher* p = (Belcher*) pv;
p->belch();
}