sml@beach.cis.ufl.edu (Shein-Fong Law) (09/10/90)
I have compiler error when I compiled the following constructor :
A::A(char* name,B* pointer):(name) // I want to pass 'name' to Base class
construtor.
where class A , B and Base are as follows:
class B : public Base
{
public:
B(char*); // This constructor requires char* (No default)
};
class Base
{
public:
Base(char* name=0); // if name is not supplied, default = NULL
};
class A: public Base
{
private:
char* priv_name;
B* to_B;
public:
A(char*,B*);
};
Why did my compiler (glokenspiel C++ 1.2 )give error ("syntax error") to
the above constructor for A ?
How can I correct the error ?
Thanks in advance. Please email to me.
Shein-fong Law
sml@beach.cis.ufl.edukaiser@ananke.stgt.sub.org (Andreas Kaiser) (09/16/90)
In a message of <Sep 10 07:21>, Shein-Fong Law (sml@beach.cis.ufl.edu ) writes:
SL> I have compiler error when I tried to compile the following :
SL> class B;
SL> class A : public Base
[.....]
SL> class Base
Wrong declaration order. A base class must be defined before it can be used as a
base class. A class can be used in a pointer or reference declararation before
it's definition, but not as variable, class member or base class.
Gruss, Andreas
--
:::::::::::::::::::: Internet: kaiser@ananke.stgt.sub.org
:: Andreas Kaiser :: Fidonet: 2:507/18.7206 (+ 2:509/5.2512)
::::::::::::::::::::