x = foo; // call func1(i);<P>foo = x; // call func2(i,x);<P>Mr. LightShiner
Overloading operator[]; Need Some Light
I have a problem that I can't figure out and I'm in the dark. Can someone please shine some light in my direction. I want to overload the subscript operator [], but I need to call different functions depending on what side of an assignment operator = it is on. Example:
One thing to watch out for when overloading multiple operators and using them together:
C++ keeps the original order of operations for overloaded operators. This can be a really cool thing if you're overloading to, say, enhance the functionality of a data type (a situation in which one of my teammates used operator overloading to allow ranges of data to be compared during computation comes to mind) but if you weren't aware of it, you can get some bizarre things happening depending on how you set up your operators.
-fel
~ When in doubt, add ()'s. ~
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement