By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,159 Members | 980 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,159 IT Pros & Developers. It's quick & easy.

parameter passing to base class constructor (definition and delcaration)

P: n/a
Hello everyone,

I have a very simple question.

Imagine that I have a CBase class with a nondefault constructor that
takes one argument CBase::CBase(int A)

And a derived class CDerived that takes two arguments.

If I am not mistaken the definition of the constructor of CDerived
should be:

CDerived::CDerived(int A, int B) : CBase(A){ }
My question is, what should the declaration of CDerived should look like
(in the .h file)?
Thank you
Vasileios

Jul 22 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Vasileios <vz******@nis.cambridge.scr.slb.com> writes:
Hello everyone,

I have a very simple question.

Imagine that I have a CBase class with a nondefault constructor that
takes one argument CBase::CBase(int A)

And a derived class CDerived that takes two arguments.

If I am not mistaken the definition of the constructor of CDerived
should be:

CDerived::CDerived(int A, int B) : CBase(A){ }
My question is, what should the declaration of CDerived should look
like (in the .h file)?


class CDerived: public CBase {
public:
CDerived(int A, int B);
};

HTH & kind regards
frank

--
Frank Schmitt
4SC AG phone: +49 89 700763-0
e-mail: frankNO DOT SPAMschmitt AT 4sc DOT com
Jul 22 '05 #2

P: n/a

"Vasileios" <vz******@nis.cambridge.scr.slb.com> wrote in message
news:3F**************@nis.cambridge.scr.slb.com...
Hello everyone,

I have a very simple question.

Imagine that I have a CBase class with a nondefault constructor that
takes one argument CBase::CBase(int A)

And a derived class CDerived that takes two arguments.

If I am not mistaken the definition of the constructor of CDerived
should be:

CDerived::CDerived(int A, int B) : CBase(A){ }

My question is, what should the declaration of CDerived should look like
(in the .h file)?


class CDerived : public CBase
{
public:
CDerived(int, int);
};
Jul 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.