C++11 - defaulted function

less than 1 minute read

C++11 introduced the defaulted function as the following example.

1
2
3
4
5
6
7
class help
{
public:
    help() = default;
private:
    std::string m_text;
}
The main reason of this feature is to compromise the case which if user define another non default constructor, complier will not generate the default constructor automatically. Sometime this is very annoying for writer so if you use the defaulted function as shown above example, user can easily generate default constructor automatically.