reference to non static member function?

I'm testing out classes, and I'm confused on how to get past the error:
"reference to non-static member function must be called; did you mean to call it with no arguments?"

Dog.h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#ifndef DOG_H_INCLUDED
#define DOG_H_INCLUDED
#include <iostream>

using namespace std;

class Dog
{
    public:
    typedef std::size_t size_type;
    static const size_type CAPACITY = 200;
    Dog() : used(0) {}
    string GetData(){return data[used];}

    void insert(const string entry);
    private:
        string data[CAPACITY];
        size_type used;

};


#endif // DOG_H_INCLUDED 


Dog.cpp

1
2
3
4
5
6
7
8
9
10
#include "Dog.h"



void Dog::insert(const string entry) {

    data[used] = entry;
    ++used;

}


main.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
#include "Dog.h"

using namespace std;

int main()
{
    cout << "Hello world!" << endl;
    Dog dog;
    dog.insert("pomeranian");
    cout << dog.GetData;
    return 0;
}

Tried "static void insert ..." already?
closed account (E0p9LyTq)
Try posting the ENTIRE error message you get.
@FurryGuy

main.cpp|11|error: reference to non-static member function must be called; did you mean to call it with no arguments?|
In main.cpp line 11 should be cout << dog.GetData();
closed account (E0p9LyTq)
No, the ENTIRE error message your compiler is showing.

something like this:

1>6-4_AmbiguousStatements.cpp
1>6-4_AmbiguousStatements.cpp(18): error C2065: 'cout': undeclared identifier

is much more helpful to figuring out what is wrong than what you post.
closed account (E0p9LyTq)
cout << dog.GetData; should be cout << dog.GetData();

GetData() is a class member function, not a class variable.
Topic archived. No new replies allowed.