Skip to content

Latest commit

 

History

History
87 lines (52 loc) · 1.94 KB

File metadata and controls

87 lines (52 loc) · 1.94 KB

 

 

 

 

 

 

'A default constructor is a constructor which needs no arguments.' [2]

 


struct MyClass {   MyClass() {}; //A default constructor   //Rest of the class };

 


struct MyClass {   MyClass(int x) : m_x(x) {}; //A default constructor   //Rest of the public part of the class   private:   int m_x;   //Rest of the private part of the class };

 

 

 

 

 

 

 

 

 

 

 

 

  1. Bjarne Stroustrup. The C++ Programming Language (4th edition). 2013. ISBN: 978-0-321-56384-2. Chapter 17.7. Advice, page 525: '[7] Give a class a default constructor if and only if there is a "natural" default value'
  2. Joint Strike Fighter Air Vehicle C++ Coding Standards for the System Development and Demonstration Program. Document Number 2RDU00001 Rev C. December 2005. 4.3.14: 'A default constructor is a constructor which needs no arguments.'