Hi there!
You are working in C++ I guess...
1. You are calling operator+() as a free function. Normally it will be a friend or member function.
2. I think int is not a class so calling an operator for that makes no sense.
You could implement a new operator for a new class you wrote (like string or Int (watch case)).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Since you are using only int's and not classes, c = a + b; should do the trick. When you start into classes it becomes a bit harder, but would still be c = a + b;
Curtis
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello, my question is:
If I write:
int a=3, b=4, c;
c=operator+(a, b);
the compiler gives me the message:
operator+ not defined
What should I do?
Franjo
Hi there!
You are working in C++ I guess...
1. You are calling operator+() as a free function. Normally it will be a friend or member function.
2. I think int is not a class so calling an operator for that makes no sense.
You could implement a new operator for a new class you wrote (like string or Int (watch case)).
Franjo,
what's wrong with:
c= a+ b;
?
Derek
Since you are using only int's and not classes, c = a + b; should do the trick. When you start into classes it becomes a bit harder, but would still be c = a + b;
Curtis
First of all thanks for respnse Curtis, Derek and Rene. I already work with classes, and within the class this code works.
Franjo