hackingcpp / comments

Comments regarding hackingcpp.com
0 stars 0 forks source link

cpp/lang/custom_type_basics #46

Open utterances-bot opened 5 months ago

utterances-bot commented 5 months ago

C++ Basic Custom Types / Classes | hacking C++

Writing a simple class in C++; how private data, constructors/member functions make it possible establish/keep invariants and how const member functions enforce data mutability guarantees.

https://hackingcpp.com/cpp/lang/custom_type_basics.html

JohannJo commented 5 months ago

In this class: class ascendingsequence { std::vector seq; // ← data member … void insert (int x) { // ← member function // insert x into nums at the right position } }; Since the vector is called "seq", you should call it seq in the comment of the insert fucntion, not "nums".