faq the c++ will not provide the default constructor?

F

fcvcnet

Hi,
If we do not provide the default constructor(non-parameter constructor),
the compiler will create one for us.
If we have a constructor with parameter and we do not provide the
non-parameter constructor, wether the compiler create default constructor
for us?
Thank you very much.
 
I

Ian Collins

fcvcnet said:
Hi,
If we do not provide the default constructor(non-parameter constructor),
the compiler will create one for us.
If we have a constructor with parameter and we do not provide the
non-parameter constructor, wether the compiler create default constructor
for us?

No, you have to provide one.
 
D

dan2online

fcvcnet said:
Hi,
If we do not provide the default constructor(non-parameter constructor),
the compiler will create one for us.
If we have a constructor with parameter and we do not provide the
non-parameter constructor, wether the compiler create default constructor
for us?

If a constructor has parameters, all the parameters have default
values. The constructor aslo is default. Otherwise, you need to provide
no-parameter constructor as default.
 
F

fcvcnet

Thank you dan2online.
If a constructor has parameters, all the parameters have default values.
Is it I must provide the default values?
The constructor aslo is default.
Is it be take as the "only one" default ctor(The word I learned just hours
ago)?

Thank you.
 

Ask a Question

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.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top