Subscript Operator Overloading

Hello
I need to build a subscript operator for my array of unsigned integers. I was wondering if the subscript operator variable type needs to be "unsigned int" as the argument like the code shown down below.

1
2
unsigned int& operator [](unsigned int); 
const unsigned int& operator [] (unsigned int) const; 

No, it doesn't need to be unsigned int. It can be whatever type you want. For example, std::map's operator overload [] can take in whatever the key type of the map is, so it could be a double, or a string, or user-defined object, etc.
Thank you!
Topic archived. No new replies allowed.