Let's say that I've got a class that wraps a raw array. I've implemented the operator[] method which is great. In implementing the at() method, I decided that I'd just use:.Code:(*this)[index]
Is that weird C++?
Let's say that I've got a class that wraps a raw array. I've implemented the operator[] method which is great. In implementing the at() method, I decided that I'd just use:.Code:(*this)[index]
Is that weird C++?
Nah, but I think you know the alternative.
this->operator[](index);
It isn't weird at all. In fact, it's the only way it should be done(in my opinion)...
Devoted my life to programming...
What is wrong with this:
operator[](index)
This is just a style preference, but I prefer not to write this everywhere in C++.
I think the weird thing here is that "this" is a pointer. But as you know, there's history there.
It is too clear and so it is hard to see.
A dunce once searched for fire with a lighted lantern.
Had he known what fire was,
He could have cooked his rice much sooner.
Well, you can
Code:MyClass& self = *this; self[123] = 345;
Code://try //{ if (a) do { f( b); } while(1); else do { f(!b); } while(1); //}