djones@megatest.UUCP (Dave Jones) (01/18/88)
In a previous posting, I made some suggestions about writing macros
for the automation of deriving classes. (See page 209 of The Book:
"Generic Classes".)
It has come to my attention that an inconsistancy in cfront effectively
squelches the scheme when constructors of derived classes need parameters.
This is apparently a legal declaration of BOTH class-foo AND the
object bar:
class foo
{ int j;
} bar;
BUT, if the class requires a parameter for the constructor, you
have trouble (and a nonsense error message):
class foo
{ int j;
public:
foo(int i) { j = i; }
}bar(5);
"foo.C", line 6: sorry, not implemented: class foo defined as
return type for bar() (did you forget a ';' after '}' ?)
THIS IS OKAY, however:
class foo
{ int j;
public:
foo(int i) { j = i; }
};
foo bar(5);
Looks like I'll have to face it: For release 1.2 at least, you need a name
and a separate declaration for every new derived class, even if you only
want to declare one object of that class, and don't care what the class
is called.