Why am I getting member declaration not found?

Why am I getting member declaration not found?

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


class Fruit
{
private:
	int type;
public:
	int getType() {return type;}
};

inline int Fruit::getType() const //error occurs here
{
	return type;
}

int main()
{
	return 0;
}
Last edited on
closed account (jwkNwA7f)
You already put the body of the function here on line 9:
int getType() {return type;}
So, you can just put this on line 9:
inline int getType() const {return type;}
And leave out lines 12-15.
Last edited on
There are two separate issues. One, you have already fully defined the function getType() on line 9. Two the declarations don't match (one has const, the other doesn't).
Thanks for the responses.
Topic archived. No new replies allowed.