Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   operator overloading (http://www.go4expert.com/forums/operator-overloading-t25406/)

hannach 3Apr2011 01:07

operator overloading
I write class Matrix, and I want to overloading the operator [][].
The prototype of this functin is:

double& Matrix::operator [][](int row,int col)
I get some errors:

error C2270: '[]' : modifiers not allowed on nonmember functions
error C2092: '[]' array element type cannot be function
error C2470: 'Matrix::[]' : looks like a function definition, but there is no parameter list; skipping apparent body

I can't understand what the problem, any suggestions?

michael j g 11Apr2011 06:14

Re: operator overloading
well if you are useing c++ you can right click on the error and then click go to line or what ever it says.
you will find it may be on one of three lines.

line up
line down


#include (iostream)
#include (string)

using name space std;
int main () //error above this line "name space"
{ //error on this line "{"
// what ever gos in this area

] // error on this line "]"

this is not the exact words that errors say it is just a way of showing errors and some positions of them.

i wish you luck with you program.

All times are GMT +5.5. The time now is 13:57.