F
Flzw
Probably a stupid question but, how do I pass arguments to the base class
constructor when I create an Instance of a derived class ?
constructor when I create an Instance of a derived class ?
Probably a stupid question but, how do I pass arguments to the base class
constructor when I create an Instance of a derived class ?
Flzw said:Probably a stupid question but, how do I pass arguments to the base class
constructor when I create an Instance of a derived class ?
Flzw said:Probably a stupid question but, how do I pass arguments to the base class
constructor when I create an Instance of a derived class ?
****Karl said:Does your textbook not cover this?
(You cannot learn a language as complex as C++ with a textbook)
Howard said:I believe this is what you're looking for:
class Derived : public Base
{
Derived( int x ) : Base( x );
};
-Howard
Karl Heinz Buchegger said:****
typo: without
--
Howard said:I believe this is what you're looking for:
class Derived : public Base
{
Derived( int x ) : Base( x );
};
Karl Heinz Buchegger said:That's a syntax error.
Howard said:[snip]
Yeah, I saw that the instant I hit Send.
^Howard said:....
I meant this:
Derived( int x ) : Base( x ) { };
(I think the initializer has to go with the *definition* of the constructor,
and my first post just had a declaration, not a definition.)
-Howard
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.