Skip to content

Instantly share code, notes, and snippets.

@scj7t4
Created December 5, 2014 16:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scj7t4/8e083741402d905f6139 to your computer and use it in GitHub Desktop.
Save scj7t4/8e083741402d905f6139 to your computer and use it in GitHub Desktop.
Brackets Operator
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