Set.h file contains in the public class :
friend const Set operator +(const Set & a, const Set & b);
Set.cpp file contains a function called:
const Set Set::operator +(const Set & a, const Set & b)
Why is it this error appears: 'const Set Set::operator+(const Set&, const Set&)' must take either zero or one argument'
-edit-
As couple of you guys suggested , removing friend front my .h file lead to two more errors
Set.h:23:53: error: 'const Set Set::operator+(const Set&, const Set&)' must take either zero or one argument const Set operator +(const Set & a, const Set & b);
Set.cpp:73:55: error: 'const Set Set::operator+(const Set&, const Set&)' must take either zero or one argument const Set Set::operator +(const Set & a, const Set & b){
-edit 2 -
const Set operator +(const Set & a, const Set & b){
Node * intersection;
while(a != nullptr && b != nullptr){
if(a->value < b->value){
intersection -> value = a;
intersecioon = intersection->next;
a=a->next;
}
if(a->value > b->value){
intersection -> value = b;
intersecioon = intersection->next;
b=b->next;
}
}
while(a != nullptr){
intersection -> value = a;
intersecioon = intersection->next;
a=a->next;
}
while(b != nullptr){
intersection -> value = b;
intersecioon = intersection->next;
b=b->next;
}
return intersection;
}
This is my operator function.
friend
, removeSet::
from the second line, i.e. in thecpp
file, define it asconst Set operator+(const Set & a, const Set & b)
. If still have problems, post a MCVE stackoverflow.com/help/mcve – vsoftco