Search code examples
c++classauto

Auto-generated class members?


When creating a class, I know of 3 Constructors/Destructors which are auto-generated if you don't specify them. The operator= is also auto-created.

Is the operator== or any other comparison operator auto-generated? Are there any other members or member functions which are created? What about the this pointer?


Solution

  • According to the latest spec I could find, section 12.1 states:

    12 Special member functions [special] 1 The default constructor (12.1), copy constructor and copy assignment operator (12.8), move constructor and move assignment operator (12.8), and destructor (12.4) are special member functions. [ Note: The implementation will implicitly declare these member functions for some class types when the program does not explicitly declare them. The implementation will implicitly define them if they are odr-used (3.2). ... ]