operator overloading

i need to overload the operator [], any ideas??
What are you having trouble with exactly? Why do you need the subscript operator?
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].
I have an idea. you could read this: http://www.cplusplus.com/doc/tutorial/classes2/
thnx :)
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
Do you mean?

char& operator[] (int pos);

Andy
@andywestken:
Yes:)
Topic archived. No new replies allowed.