If you declare an empty class like below, compiler will add all the below functions by default:
class T{}
====
class T {
// default constructor
T() {}
// copy constructor
T(T const& rhs) {}
// destructor
~T() {}
// assignment operator
T& operator=(T const& rhs) { return *this; }
//Move constructor C++11
T(T&& other){}
//Move assignment operator C++11
T& operator=(T&& other){}
};
====
class T{}
====
class T {
// default constructor
T() {}
// copy constructor
T(T const& rhs) {}
// destructor
~T() {}
// assignment operator
T& operator=(T const& rhs) { return *this; }
//Move constructor C++11
T(T&& other){}
//Move assignment operator C++11
T& operator=(T&& other){}
};
====
No comments:
Post a Comment