Which methods will compiler automatically generate for the following class?
class A
{
};
Explanation
The idea of compiler-generated functions is that, if some functions of a class are so trivial to write that their code would nearly be boilerplate, the compiler will take care of writing them for you.

This feature has been here since C++98, where the compiler would try to generate:
- a default constructor X(), that calls the default constructor of each class member and base class,
- a copy constructor X(X const& other), that calls a copy constructor on each member and base class,
- a copy assignment operator X& operator=(X const& other), that calls a copy assignment operator on each class member and base class,
- the destructor ~X(), that calls the destructor of each class member and base class. Note that this default-generated destructor is never virtual (unless it is for a class inheriting from one that has a virtual destructor).

With C++11, the compiler generates 2 new functions related to move semantics:
- a move constructor X(X&& other), that calls a move constructor of each class member and base class,
- a move assignment operator X& operator=(X&& other), that calls a move assignment operator on each class member and base class.
Read more

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Cosmo
Зареєструйся Зараз
або Підпишись на майбутні тести