Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Class operator overloading the subscript and boundary check for array
//clang 3.8.0 #include <cassert> #include <iostream> class IntList{ private: int m_intList[10]; public: int& operator[](const int); }; int& IntList::operator[](const int index){ assert(index>=0&&index<10); return m_intList[index]; } int main() { IntList list; list[4]=7;; std::cout << list[4]; }
run
|
edit
|
history
|
help
0
Crow unordered_map Quiz
ECE2574_Function_Calling_Example
Maze problem solution
C++ Register
selection sort
Throttle Example in C++ (80 requests every 2 seconds)
12/2
my override
pointer to pointer
non-deduced context