Help with operator overloading

I can't figure out how to overload the operator = without getting the error "must be non static member function." I'm using g++.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class VectorDouble
{
public:
    VectorDouble(){max_count=50;array=new double[max_count];};
    VectorDouble(int a){max_count=a;array=new double[max_count];};
    VectorDouble(VectorDouble &VD){};
    ~VectorDouble(){delete[] array;};
    friend bool operator== (const VectorDouble &v1,const VectorDouble &v2);
    int capacity(){return max_count;};
    int size(){return count;};
    int value_at(int i);
    void change_value_at(int d,int i);
    VectorDouble &operator= (VectorDouble &v1);
private:
    double *array;
    int max_count, count;
};


This is in another cpp file.
1
2
3
4
VectorDouble &operator= (VectorDouble &v1)
{

}
well, that's different. Didn't know it couldn't be declared outside the class. thanks for the link
see this for an operator to be defined outside of a class.

http://www.cplusplus.com/forum/general/43248/
Topic archived. No new replies allowed.