Question on dynamic casting scope
Philippe Bouchard
philippeb@corel.com
Tue Nov 21 07:33:00 GMT 2000
The following program:
#include <iostream>
int main();
struct A
{
ÃÂ virtual ~A() {}
};
struct B
{
ÃÂ virtual ~B() {}
};
struct O : A, private B
{
ÃÂ friend int main();
ÃÂ virtual ~O() {}
};
int main()
{
ÃÂ using namespace std;
ÃÂ A * p = new O;
ÃÂ cout << "A * = " << dynamic_cast<A *>(p) <<
endl;
ÃÂ cout << "B * = " << dynamic_cast<B *>(p)
<< endl;
ÃÂ cout << "O * = " << dynamic_cast<O *>(p)
<< endl;
}
Outputs:
A * = 0x8049fd0
B * = (nil)
O * = 0x8049fd0
Notice:
If I the inheritance of B into O becomes public, the address of B *
becomes 0x8049df4.
Question:
I was wondering why friendship is not affecting dynamic casting scope.
Thank you.
ÃÂ
begin:vcard
n:Bouchard;Philippe
x-mozilla-html:FALSE
org:Corel Linux
adr:;;;;;;
version:2.1
email;internet:philippeb@corel.com
title:Software Engineer
x-mozilla-cpt:;0
fn:Philippe Bouchard
end:vcard
More information about the Gcc-bugs
mailing list