reference to non-static member function must be called

How can I fix it?
Help me! :)

1
2
3
4
5
6
7
8
9
10
11
myvector myvector :: operator+(const myvector &ref) const
{
    myvector e(ref.size);
    int i;
    for (i=0; i<ref.size; i++)    ///ref.size error :reference to 
                                  ///non-static member function must be called
    {
        e[i] = this ->arr[i] + ref.arr[i];
    }
    return e;
}



header file
1
2
3
4
5
6
7
8
9
10
11
12
13
class myvector{

    public:
        double * arr;
        int arrlen;
        double xpos, ypos;
        
    
        myvector();
        myvector(int size);
        int size();
        double norm();
        void resize(int newsize);
1
2
3
4
5
6
7
8
9
10
myvector myvector :: operator+(const myvector &ref) const
{
    myvector e(ref.size()); //add parenthesis to ref.size
    int i;
    for (i=0; i<ref.size(); i++) //add parenthesis to ref.size
    {
        e[i] = this ->arr[i] + ref.arr[i];
    }
    return e;
}
Last edited on
The function size is like this... ref.size(), line 3 and 5
Topic archived. No new replies allowed.