Hello there~
Well, straight for the problem:
I have a class with a private vector that stores pointers:
class MyClass{
private:
vector<myOtherCls*> myVector;
public:
//using the following till now:
vector<myOtherCls*>& getContainer();
};
class myOtherCls{
public:
void someGetFunc();
};
Now I dont want to use getContainer()
but rather he Subscript-Operator.
MyClass cls;
//current call:
cls->getContainer()[i]->someGetFunc();
//but I want to use:
cls[i]->someGetFunc();
With just the []-overload in MyClass it wont work...
public:
//...
inline myOtherClass*& operator[](unsigned int index){
return myVector[index];
//same as:
//return (*(myVector.begin() + index));
}
};
When I compile, I get the following errors:
error C2819: type 'MyClass' does not have an overloaded member 'operator ->'
error C2232: '->MyClass::someGetFunc' : left operand has 'class' type, use '.'
error C2039: 'getNode' : is not a member of 'MyClass'
Woah, wall of text.. sorry for that, but I hope someone has an idea to solve teh problem. x.x
Greetz, RF~