i have a problem with overloading the addition. this is an example i made to test overloading, but i get a compiler error: "iso c++ forbids declaration of operator+ with no type"
i hope you can help me
#include <iostream>
template <typename T>
class foo
{
public:
foo();
T value;
void setValue(T svalue);
friend foo<T> operator+(foo<T> const &foo1, foo<T> const &foo2);
};
template<typename T>
foo<T> operator+(foo<T> const &foo1, foo<T> const &foo2)
{
return foo1.value + foo2.value;
}
template <typename T>
foo<T>::foo()
{
value = 0;
}
template <typename T>
void foo<T>::setValue(T svalue)
{
value = svalue;
}
int
main()
{
foo<int> ten;
ten.setValue(10);
foo<int> five;
five.setValue(5);
return 0;
}
//edit: sorry, i changed the classname from kamehameha to foo, some kamehameha's were left...
//edit2: i added the return type, now the compiler says: "warning: friend declaration 'foo operator+(foo, foo))' declares a non-template function
'foo foo::operator+(const foo&, const foo&)' must take either zero or one argument