friend myList<T> operator +( myList<T> &c1,myList<T> &c2);
myList<T> operator +(myList<T> &c1, myList<T> &c2)
{
int len1 = c1.getLength();
int len2 = c2.getLength();
int newLen = len1+len2;
int newSize = newLen;
T * newList = new T[newSize];
for(int i = 0;i<len1;i++){
newList[i] = c1.data[i];
}
for(int j=len1;j<newLen;j++){
newList[j] = c2.data[j-len1];
}
delete c1.data;
c1.data = newList;
c1.size = newSize;
c1.length = newLen;
return *c1;
}
void main(){
myList<int> *a = new myList<int>(5);
myList<int> *b = new myList<int>(5);
a+b;
}
errormessage:invalid operands of types 'myList < int >*
' and 'myList< int > *
' to binary 'operator+' when I call 'a+b
', so how should I do to make it right ?