Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #14370
| From | Oliver <fwang2@gmail.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | question on no-argument constructor |
| Date | 2012-02-21 05:26 -0800 |
| Organization | http://groups.google.com |
| Message-ID | <18415058.42.1329830819543.JavaMail.geo-discussion-forums@vbne13> (permalink) |
hi, all -
I have a newbie question: suppose I have a user-defined class that must take a argument to properly initialize. so I have something like:
class Foo {
explicit Foo(const string &str);
...
}
Another class define Foo as its member:
class Bar {
private:
Foo foo;
}
Now the compiler complains that it can find the candidate constructor. So it seems I must define a no-argument constructor for Foo ... at the risk of the object can exist without being properly initialized? I must have missed something ...
Thanks for your help
Oliver
Back to comp.lang.c++ | Previous | Next — Next in thread | Find similar | Unroll thread
question on no-argument constructor Oliver <fwang2@gmail.com> - 2012-02-21 05:26 -0800
Re: question on no-argument constructor "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2012-02-21 14:32 +0100
Re: question on no-argument constructor Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-21 05:44 -0800
Re: question on no-argument constructor "Fred Zwarts \(KVI\)" <F.Zwarts@KVI.nl> - 2012-02-21 14:44 +0100
Re: question on no-argument constructor Oliver <fwang2@gmail.com> - 2012-02-21 06:41 -0800
Re: question on no-argument constructor Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-21 08:14 -0800
Re: question on no-argument constructor Juha Nieminen <nospam@thanks.invalid> - 2012-02-21 17:00 +0000
Re: question on no-argument constructor Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-02-21 21:12 +0000
Re: question on no-argument constructor Goran <goran.pusic@gmail.com> - 2012-02-21 23:44 -0800
csiph-web