 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
bml Guest
|
Posted: Fri Jan 30, 2004 8:18 pm Post subject: trivial constructor |
|
|
Is "Trivial constructor" either a default constructor generated by compiler
or the one you write but it does nothing (empty inside method definition)?
Is it required by C++ standard to bypass "construction" in case of trivial
constructor, or just implementation-dependent?
In which cases is a construction bypassed?
Thanks a lot!
|
|
| Back to top |
|
 |
Ron Natalie Guest
|
Posted: Fri Jan 30, 2004 8:28 pm Post subject: Re: trivial constructor |
|
|
"bml" <lee4rai (AT) yahoo (DOT) com> wrote
| Quote: | Is "Trivial constructor" either a default constructor generated by compiler
or the one you write but it does nothing (empty inside method definition)?
Is it required by C++ standard to bypass "construction" in case of trivial
constructor, or just implementation-dependent?
In which cases is a construction bypassed?
|
To answer the questions in reverse order. No construction occurs when the
constructor is trivial.
However, for a class to have a trivial constructor means more than it just has
the compiler generated one. The class also needs to have no virtual functions,
no virtual bases, and all of it's subobjects (bases and non-static members) must
also have trivial constructors.
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|