Basic setter and getter definition

Hello! I am new to C++ and I am coding my first programs but I have a couple problems here (though very basic, I guess).

I just want to define a class and its setters and getters methods but I am doing something wrong about the class members accessibility. In this case, I want to make a line which is defined by a group of Squares

Line.h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include "Square.h"
#include <vector>


class Line
{
public:
	typedef std::vector<Square> vSquare;
	
	Line(void);
	~Line(void);
	vSquare getBody();
	void setBody(vSquare);

private:

	vSquare Body;



Line.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "Line.h"

typedef std::vector<Square> vSquare;

Line::Line(void)
{
}


Line::~Line(void)
{
}

vSquare getBody(void)
{
    return Line::Body;	
}

void setBody(std::vector<Square> vecSq)
{
    Line::Body=vecSq;
}



In the definition of methods getBody and setBody, the compiler tells me that Body is inaccessible. I know that I declared it in the private section but all the examples I have read, there was no problem with this. If I write only Body instead of Line::Body, it doesn't recognize variable Body.

Could you please help me?

Thanks in advance!
You forgot to add Line:: before the function names on lin 14 and 19.
Thanks a lot Peter87!

That was the problem.

protip: never code with hangover
Topic archived. No new replies allowed.