why in this code, I got a error: left operand must be l-value. The pointer is a modifiable value, but why I got this reminder.
But when I give member function of the following, it works...
What you are doing is the same as 2 = 5;. You are returning a prvalue, a temporary, distinct from original number. You cannot assign anything to it, and even if you could, original value would not be changed.
Look at return type of JLBorges code. It is a reference to value. Any modifications to it will be reflected on original value. So you need a reference to your return type. In your case cocos2d::Sprite*& operator[](int n) { would suffice.