C++C++11C++14C++17Introduction to C++Learn C++

Learn about Eligible Default Constructor in C++

Do you want to learn what is Eligible Default Constructor or what kind of methods we have that we can declare and use Eligible default constructors? In this post, we will try to explain the Eligible Default Constructor with examples.

The Constructor in C++ is a function, a method in the class, but it is a ‘special method’ that is automatically called when an object of a class is created. We don’t need to call this function. Whenever a new object of a class is created, the Constructor allows the class to initialize member variables or allocate storage. This is why the name Constructor is given to this special method.

There are different contractor types and the Default Constructor in classes is one of these. This method not only used in classes but also used with struct and union data types.

Default Constructor is a constructor type in Classes that is called when class is defined with no arguments, or it is defined with an empty parameter list, or with default arguments provided for every parameter. A type with a public default constructor is Default Constructible; There are different methods to use this Default Constructor and one of the terms that we meet sometimes is Eligible Default Constructor. If you are looking for what is Eligible Default Constructor in C++, please read below.

Eligible Default Constructor

The Eligible Default Constructor is a default constructor which is either user-declared or both implicitly-declared and definable (until C++11). The triviality of eligible default constructors determines if the class is an implicit-lifetime type or if the class is a trivial type.

A default constructor is eligible if only all below are provided,

  • it is not deleted (C++11, C++20)
  • its associated constraints, if any, are satisfied (C++20)
  • no default constructor is more constrained than it (C++20).

Here is an Eligible Default Constructor example,

Get started building powerful apps with C++Builder!


Oh hi there 👋
It’s nice to meet you.

Sign up to receive awesome C++ content in your inbox, every day.

We don’t spam! Read our privacy policy for more info.

About author

33+ years of coding with more than 30+ programming languages, mostly C++ on Windows, Android, Mac-OS, iOS, Linux and some other operating systems. Dr. Yilmaz Yoru was born in 1974, Eskisehir-Turkey. He graduated from the department of Mechanical Engineering of Eskisehir Osmangazi University in 1997. One year later he started to work in the same university as an assistant. He received his MSc and PhD degrees from the same department of the same university. He has married and he is a father of a son. Some of his interests are Programming, Thermodynamics, Fluid Mechanics and Artificial Intelligence. He also likes the graphical 2D & 3D design and high-end innovations.
Related posts
C++C++11C++14C++17Generic ProgrammingLearn C++Templates

What Is A Template In C++?

C++C++17Code SnippetComponentsIteratorsLearn C++

What Are The Boost C++ Libraries?

C++C++17Introduction to C++Learn C++Syntax

Learn Bits and How To Use std::bitset In C++

C++C++17IteratorsLearn C++

How To Use Insert In std::map In Modern C++

Worth reading...
Learn about Eligible Default Constructor in C++