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.
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".
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