So i'm messing around with the operator[] since prof wasn't very clear on it but I get a build error for multiple definitions. I code mainly on cLion, I tested it on the latest Eclipse too same error. TO BE CLEAR! I get this error only when the function def is outside with the prototype inside the class, so if I define the function inside the class I don't get the error. My class code is as follows.
> I get this error only when the function def is outside with the prototype inside the class,
> so if I define the function inside the class I don't get the error.
When the function definition is outside the class, make sure that you have not omitted the const qualifier. int myClass::operator[](int index) const { ...
If you define myClass::operator[] outside the class body in a header file and then include that header in two or more source files then you will get a Multiple Definition Error if you have forgotten to mark the method as inline. That is: