frei@rubmez.UUCP (Matthias Frei) (01/31/89)
I'm working with cfront 1.2.1 and found something I don't understand.
I'm trying to declare a private member function get_a of class foo
returning a pointer to a structure struct_a.
I want this struct only to be known inside foo. So I declare it
immediately after "class foo { ". This runs into an error message:
CC foo.C:
"foo.C", line 6: error: syntax error
"foo.C", line 8: error: foo::get_a() type mismatch: A_STRUCT *foo::() and int foo::()
2 errors
If I declare it outside from foo. everything is all rigth.
look at the following code for an example:
-- foo.h ---
#ifdef BUG
class foo { // This variant produces an error
#endif
typedef struct a_struct { int i; int j; } A_STRUCT;
#ifndef BUG
class foo { // Variant without error
#endif
int priv_a;
A_STRUCT struct_a;
private:
A_STRUCT *get_a();
public:
foo();
};
-- foo.C ---
#include "foo.h"
foo::foo()
{ priv_a = 1; }
A_STRUCT *
foo::get_a()
{ return & struct_a; }
I can't see that Stroustrup's definition violates to decalre a struct inside
a class and use it by a private member. So I think it's a bug.
Any comments gracefully accepted.
Matthias Frei
--
Snail-mail: | E-Mail address:
Microelectronics Center | UUCP frei@rubmez.uucp
University of Bochum, W-Germany | (...uunet!unido!rubmez!frei)
D-4630 Bochum, P.O.-Box 102143 |