Created
December 5, 2014 16:07
-
-
Save scj7t4/8e083741402d905f6139 to your computer and use it in GitHub Desktop.
Brackets Operator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Pair | |
{ | |
private: | |
int m_val1; | |
int m_val2; | |
public: | |
int operator[](int index) const; | |
}; | |
int Pair::operator[](int index) const | |
{ | |
if(index == 0) | |
return m_val1; | |
else | |
return m_val2; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment