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

A doubt regarding constructors

P: n/a
Hi all,
While reading some propriotary C++ code, I came across following
constructor:

ClassA::ClassA(arg1,arg2) : ClassB(arg_1, arg_2)
From my limited knowledge of C++, i can guess that this is some kind of

constructor.
But what 'is' this exactly? Its the ':' symbol - the inheritance thing
that's confusing me.

In the definition of ClassB, under 'public' members, 'ClassB(arg_1,
arg_2);' appears again.
Also, the documentation there calls it a constructor.

Is it something like constructor-inheritance?

I'll be glad if someone explains this.

Thanks,
Chaitanya.

Apr 18 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a

cs*****@gmail.com wrote:
Hi all,
While reading some propriotary C++ code, I came across following
constructor:

ClassA::ClassA(arg1,arg2) : ClassB(arg_1, arg_2)
From my limited knowledge of C++, i can guess that this is some kind of

constructor.


Look up initialization lists. See:
http://www.parashift.com/c++-faq-lit....html#faq-10.6

Regards,
Sumit.

Apr 18 '06 #2

P: n/a

cs*****@gmail.com wrote:
Hi all,
While reading some propriotary C++ code, I came across following
constructor:

ClassA::ClassA(arg1,arg2) : ClassB(arg_1, arg_2)
From my limited knowledge of C++, i can guess that this is some kind of

constructor.
But what 'is' this exactly? Its the ':' symbol - the inheritance thing
that's confusing me.

In the definition of ClassB, under 'public' members, 'ClassB(arg_1,
arg_2);' appears again.
Also, the documentation there calls it a constructor.

Is it something like constructor-inheritance?

I'll be glad if someone explains this.

Thanks,
Chaitanya.


seems to be like class A is inherting class B.

Apr 18 '06 #3

P: n/a
Thanks a lot!
It helped.

Apr 18 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.