Board index » cppbuilder » Re: scope

Re: scope


2007-10-21 12:53:09 AM
cppbuilder5
"Leo Siefert"
Quote
Fraser Ross wrote:

>Comeau Online has some different error messages.
>Here is the program I originally had:
>...
>std::cout<<C::B1::a; //comeau ok, Borland E2090 Qualifier 'B1' is
>not a class or namespace name
>std::cout<<C::B2::a; //comeau ok, Borland E2090 Qualifier 'B2' is
>not a class or namespace name

That is a bug in the CodeGear compiler.
"C::" isn't doing anything thats required. I see this as a bug with
Comeau and not Borland.
Quote
In this case the B1:: and B2:: qualifiers are necessary to
disambiguate between the two class members.
The 2 that aren't hidden, yes. There are 4 a int members in a C object.
An expression such as "C::B1::" specifies a nested class B1 within class
C or a namespace B1 within namespace C or some other combination. That
specified class/namespace is simply a class/namespace alone and its
position within any class hierarchy cannot be specified. C++ does not
have much support for explicitly specifying a subobject. When there is
a common base class the language is weak.
Fraser.
 
 

Re:Re: scope

"Fraser Ross"
Quote
"C::" isn't doing anything thats required. I see this as a bug with
Comeau and not Borland.
I wonder now if the bug is with Borland and is the bug I was reporting.
Anyway I'm going to learn about 'class name injection'.
Fraser.
 

Re:Re: scope

Fraser Ross wrote:
Quote
"C::" isn't doing anything thats required.
I see this as a bug with Comeau and not Borland.
I missed the superfluous C:: when I looked at the code, but you are
right. Need to do more research here.
Quote
The 2 that aren't hidden, yes. There are 4 a int members in a C object.
Probably not a very good design. Could confuse someone. <g>
Quote
When there is a common base class the language is weak.
I think that is true, and in some cases that leaves the compiler
vendors to try to settle the issue.
- Leo
 

{smallsort}

Re:Re: scope

Maybe you should make a new report stating that 'class name injection'
is not supported. Sergiy suggested a workaround in his post. I didn't
quite understand his writing. I'm not sure if there is any workaround
for class templates.
Fraser.
 

Re:Re: scope

Fraser Ross wrote:
Quote
Maybe you should make a new report ...
Possibly when I have time to wrestle with a problem like that. I would
want to understand the issue and the standard document better before
doing that, and right now I'm wrestling with some issues in my own
work and my spare time is rather short.
- Leo
 

Re:Re: scope

"Fraser Ross" < XXXX@XXXXX.COM >wrote in message
Quote
Maybe you should make a new report stating that 'class name injection'
is not supported. Sergiy suggested a workaround in his post. I didn't
quite understand his writing. I'm not sure if there is any workaround
what I suggested: if BCB does not inject the name of the class in
the class scope, we can explicitely declare the name in the
immediate derived class
struct A
{
int a;
};
struct B : A
{
typedef A A; // added
};
struct C : B
{
typedef B B; // added
void f()
{
C::B::A::a =1; // works now
}
};
Cheers,
Serge
 

Re:Re: scope

"Sergiy Kanilo"
Quote
"Fraser Ross"
>Maybe you should make a new report stating that 'class name
injection'
>is not supported. Sergiy suggested a workaround in his post. I
didn't
>quite understand his writing. I'm not sure if there is any
workaround

what I suggested: if BCB does not inject the name of the class in
the class scope, we can explicitely declare the name in the
immediate derived class
I understood the workaround but not your writing here because there are
one or two typos:
"There is no need to inject the name of the base class into scope of
derived,
because the base class injects its name is its scope, and this name is
simply
inherited"
Fraser.
 

Re:Re: scope

"Sergiy Kanilo" < XXXX@XXXXX.COM >wrote:
Quote
struct A
{
int a;
};
struct B : A
{
typedef A A; // added
};
struct C : B
{
typedef B B; // added
void f()
{
C::B::A::a =1; // works now
}
};
Man, this is smart and seems to comply the Standard. B and A in
C::B::A are now members of classes and the qualified name
lookup finds them (see my last post no. 51936).
Vaclav