#include <iostream>
class Fruit
{
private:
int type;
public:
int getType() {return type;}
};
inlineint Fruit::getType() const //error occurs here
{
return type;
}
int main()
{
return 0;
}
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: inlineint getType() const {return type;}
And leave out lines 12-15.
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).