We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
In modern c++ (c++11,14,17 and so on) there is uniform initialization rules. It is a good habit to use the curly braces {} to specify either default construction (as was happening accidentally in your case) or supply params if using a different constructor. You can do this right in the header file when you declare the variable and avoid adding ugly initialization clauses just before the constructor body as was needed in the past. Although the default constructor will still save you using the curly braces makes your intention more clear to programmers reading your code.
classA{A()=default;private:boolisWord{};};
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Tries: Contacts
You are viewing a single comment's thread. Return to all comments →
In modern c++ (c++11,14,17 and so on) there is uniform initialization rules. It is a good habit to use the curly braces {} to specify either default construction (as was happening accidentally in your case) or supply params if using a different constructor. You can do this right in the header file when you declare the variable and avoid adding ugly initialization clauses just before the constructor body as was needed in the past. Although the default constructor will still save you using the curly braces makes your intention more clear to programmers reading your code.