Inheritance syntax question
I have a question about the syntax involved in inheritance. I have a parent
class, and a child class. When I create an instance of the class, I pass to
it 3 parameters. Two of them are used by the child class, one by the parent
class. I can do this:
class Child
{
public:
Child( int parm1, int parm2, int parm3) : Parent( parm3)
{
_parm1 = parm1;
_parm2 = parm2;
}
}
And it works. I run into problems when I want to move the implementation of
the consructor outside of the class definition. If I'm not passing a parm up
to the parent, this is no problem - I simple create a Child::Child(...)
method outside of the class definition, and it works fine. How do you do
this and pass a parm up to the parent? If I try:
class Child
{
public:
Child( int parm1, int parm2, int parm3) : Parent( parm3)
}
Child::Child( ....){...}
I get compile error. If I try:
class Child
{
public:
Child( int parm1, int parm2, int parm3)
}
Child::Child( ....) : Parent( parm3){...}
I likewise get compile errors. Can you not move the implementation of the
consructor outside of the class definition in a case like this? If so, can
some kind soul give me an example of the correct syntax, or point me to an
example? I've looked at a lot of examples, but have not found one case of
the implementation of the constructor being outside of the class definition
when you pass parms to the constructor, and then pass some of the parms up
to the parent class constructor.