Topic: Forward class declarations stricter in CW5?
Author: joseph@joebloe.maple-shade.nj.us (Joseph "Moof-in'" Hall)
Date: Mon, 9 Jan 95 04:43:39 MST Raw View
In article <atotic-0801952058390001@nonlinear.mcom.com> (comp.sys.mac.programmer.codewarrior), atotic@mcom.com (Aleksandar Totic) writes:
) Certain kind of class declarations used to work in CW4, and does not in CW5.
) For example:
)
) //class B; if this line is commented out, compiler complains of "type
) // mismatch in the program bellow
) class A {
) class B * b;
) };
)
) class B {
) short b1;
) short b2;
) };
Hmm. This looks kind of like an incomplete declaration of a class B
declared in an inner scope class A to me. I don't have an ARM handy
at the moment nor do I know whether the ARM is still current on this
topic, but I'd say that if you want to refer to a class B declared in
an outer scope you're out of luck unless you get on the ball and
declare the incomplete type at global scope, or do something like
class A {
class ::B *b;
};
Well, offhand I'd say that. However, I just tried out your example
on my copy of CW5 (under 68k) and, well, it compiles fine as is.
My suggestion, OTOH, doesn't compile, yielding a "B is not a
struct/union/class member" error. Well, ok ....
Perhaps the scope resolution operator can't be applied to class
names in this way; I dunno. I'm crossposting this to comp.std.c++
for discussion since even if I did have my ARM handy I wouldn't trust
it on this point now after all the tweaks that have transpired
over the past couple of years. I vaguely recall that only
a class name can follow the "class" keyword, but in that case
I wonder why the class B created in your example above wasn't
treated as a class locally declared in class A.
So, uh, how did you get the example above to produce an error
at compile time, anyway? As I said, I'm using 68k CW5 Gold and
it works fine for me.
=============== O Fortuna, velut Luna, statu variabilis ===============
uunet!joebloe!joseph (602) 732-2549 day joseph%joebloe@uunet.uu.net
1400 N Alma School #163 Chandler, AZ 85224
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Be hip! Support comp.sys.mac.programmer.moof!
Author: atotic@mcom.com (Aleksandar Totic)
Date: Mon, 09 Jan 1995 10:31:30 -0800 Raw View
In article <01050166.jcrrqe@joebloe.maple-shade.nj.us>,
joseph@joebloe.maple-shade.nj.us wrote:
> In article <atotic-0801952058390001@nonlinear.mcom.com>
(comp.sys.mac.programmer.codewarrior), atotic@mcom.com (Aleksandar Totic)
writes:
> ) Certain kind of class declarations used to work in CW4, and does not in CW5.
> ) For example:
> )
> ) //class B; if this line is commented out, compiler complains of "type
> ) // mismatch in the program bellow
> ) class A {
> ) class B * b;
> ) };
> )
> ) class B {
> ) short b1;
> ) short b2;
> ) };
> ) main()
> )
>
> So, uh, how did you get the example above to produce an error
> at compile time, anyway? As I said, I'm using 68k CW5 Gold and
> it works fine for me.
Actaully, my example was an abstraction of the problem that occured in my
code, I did not test it:
Here is a real example that does produce an error:
class A {
public:
class B * b;
};
class B {
public:
short b1;
short b2;
};
main() {
B * b;
A * a;
a->b = b;
}
Error : type mismatch
test.cp line 15 a->b = b;
Aleks
--
Aleksandar Totic
Mozilla Development Team