You are here:

C++/constructor overloading


what is the difference between constructor overloading and function overloading?

Primarily function overloading applies to functions (including class member functions) and constructor overloading to class constructors only.

Note that constructors can be considered as special member functions. In fact they, together with destructors, conversion functions etc. are placed in a section of the ISO C++ standard titled "Special Member Functions".

So it could be said that function overloading applies to constructors and operator overload functions. That is function overloading is quite a wide, general term.

Constructor overloading on the other hand is much narrow in scope, applying as I said only to special constructor functions of classes.

One point about explicit constructor declarations is their effect on those the compiler generates for you. Even if you declare no constructors for a class the compiler will still provide both a default and a copy constructor for your class (if possible). So you could say that a class usually has at least two constructor overloads. If you declare any constructor(s) at all then the compiler will not generate a default constructor. However, unless a copy constructor is explicitly declared, the compiler will still generate a copy constructor for you. So if you want a class with only one constructor declared you would have to declare a copy constructor, and only a copy constructor, explicitly.

Not I have said declared above. While the compiler generated constructors are declared and defined, you only need to declare a constructor to cause related suppression of compiler generated constructors - this is in fact used in the current idiom for defining non copiable (and almost always non-assignable as well) class objects:

   class NotCopyiable
   // Private _declarations only_ for copy and assignment

       NotCopyiable( NotCopyiable const & );
       NotCopyiable & operator=( NotCopyiable const & );

   // ...


The above works at two levels:

By declaring the copy constructor (and assignment operator) at all suppresses the compiler generated public defaults and by making them private we ensure it is very difficult to use them - only class members and friends can access them.

By only declaring and never defining these operations we ensure that the remaining cases of copying or assigning a NotCopyiable instance that compile will fail to link as they have no definitions.

Hope this helps a bit. If this was not really what you wanted to know then please post a further, possibly follow up, question.  


All Answers

Answers by Expert:

Ask Experts


Ralph McArdell


I am a software developer with more than 15 years C++ experience and over 25 years experience developing a wide variety of applications for Windows NT/2000/XP, UNIX, Linux and other platforms. I can help with basic to advanced C++, C (although I do not write just-C much if at all these days so maybe ask in the C section about purely C matters), software development and many platform specific and system development problems.


My career started in the mid 1980s working as a batch process operator for the now defunct Inner London Education Authority, working on Prime mini computers. I then moved into the role of Programmer / Analyst, also on the Primes, then into technical support and finally into the micro computing section, using a variety of 16 and 8 bit machines. Following the demise of the ILEA I worked for a small company, now gone, called Hodos. I worked on a part task train simulator using C and the Intel DVI (Digital Video Interactive) - the hardware based predecessor to Indeo. Other projects included a CGI based train simulator (different goals to the first), and various other projects in C and Visual Basic (er, version 1 that is). When Hodos went into receivership I went freelance and finally managed to start working in C++. I initially had contracts working on train simulators (surprise) and multimedia - I worked on many of the Dorling Kindersley CD-ROM titles and wrote the screensaver games for the Wallace and Gromit Cracking Animator CD. My more recent contracts have been more traditionally IT based, working predominately in C++ on MS Windows NT, 2000. XP, Linux and UN*X. These projects have had wide ranging additional skill sets including system analysis and design, databases and SQL in various guises, C#, client server and remoting, cross porting applications between platforms and various client development processes. I have an interest in the development of the C++ core language and libraries and try to keep up with at least some of the papers on the ISO C++ Standard Committee site at


©2016 All rights reserved.