trivial constructor

B

bml

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!
 
R

Ron Natalie

bml said:
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.
 

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

Forum statistics

Threads
474,159
Messages
2,570,885
Members
47,419
Latest member
ArturoBres

Latest Threads

Top