Aug 5, 2011 at 9:31pm
i need to overload the operator [], any ideas??
Aug 5, 2011 at 9:35pm
What are you having trouble with exactly? Why do you need the subscript operator?
Aug 5, 2011 at 9:36pm
i have an assignment to create the type string as a class and i need to overload the operator [] so that i can use x[i].
Aug 6, 2011 at 2:25am
The declaration inside your class would look something like:
|
char& operator[] (int pos);
|
Then, you can treat it just like a regular function.
Last edited on Aug 6, 2011 at 2:14pm
Aug 6, 2011 at 1:59pm
Do you mean?
char& operator[] (int pos);
Andy