I am trying to overload various operators for a class I am creating. In this instance, I am trying the assignment operator. I get the same error for all of them, so I will post just the assignment operator:
// header
Code:
#include <cstdio>
#include <iostream>
namespace mine {
template<class type>
class vector
{
public:
...
vector& operator=(const vector& other);
...
};
}
and the implementation
Code:
#include "vector.h"
#include <cstdio>
#include <iostream>
template<class type>
vector& vector::vector<type>::operator=(const vector& other) {
if(&other != this) {
ptr = new type [other.n];
for (int i = 0; i < other.n; i++) {
ptr[i] = other.ptr[i];
}
}
}
I've tried various combinations of scoping on the implementation to see if it would do anything but I keep getting the:
"Expected constructor, destructor, or type conversion before '&' token" error.
I am running this on a Mac OSX Snow Leopard 10.6.2 with Xcode Version 3.2.1. Please Help!