
what does “default” mean after a class’ function declaration?
class {
C(const C&) = default;
C& operator=(const C&) = default;
~C() {}
}
- It means that you want to use the compiler-genearated version of that function, so you don’t need to specify a boyd.
- You can alse use = delete to specify that you don’t want the compiler to generate that function automactically.
- With the introduction of move constructors and move assignment operators, the rules for when automatic versions constructors, destructors and assignment operators are generated has become quite comples. Using = default adn = delete makes things easier as you don’t need to remember the rules: You just say what you want to happen.




近期评论