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
Делим на Ноль
SceneGraph Interviewee Task
34534
Array-Based Heap Example Solution
appliWall
Simple Generic Data Type Example
Initialise arrays with N number
FUCK
hw 1 os
std::set custom ordering with composition