Original Post
I am getting an error in my Minion.cpp when I am declaring(right word?) getPos()
The Error is:
In function 'Position getPos()':
|17|error: 'Pos' was not declared in this scope
||=== Build finished: 1 errors, 0 warnings ===|
If I remove the getPos() function then I can complile it. I guess what is really confusing me here is that Minion(Position P) uses the Pos variable so I "know" it is in scope.
Thanks for the help guys, here is my Code.
This is my Minion.cpp file.
#include "../include/Minion.h"
Minion::Minion(Position P)
{
Pos = P;
}
Minion::~Minion()
{
//dtor
}
Position getPos()
{
return Pos;
}
This is my Minion.h file:
#ifndef MINION_H
#define MINION_H
#include "../include/Position.h"
class Minion
{
public:
Minion(Position);
virtual ~Minion();
float getPos();
void Draw();
protected:
private:
Position Pos;
double health;
};
#endif // MINION_H
And this is my Position structure that I am going to be using globaly and passing as variables to a lot of functions:
#ifndef POSITION_H_INCLUDED
#define POSITION_H_INCLUDED
struct Position{
float Xpos;
float Ypos;
};
#endif // POSITION_H_INCLUDED
The Error is:
In function 'Position getPos()':
|17|error: 'Pos' was not declared in this scope
||=== Build finished: 1 errors, 0 warnings ===|
If I remove the getPos() function then I can complile it. I guess what is really confusing me here is that Minion(Position P) uses the Pos variable so I "know" it is in scope.
Thanks for the help guys, here is my Code.
This is my Minion.cpp file.
#include "../include/Minion.h"
Minion::Minion(Position P)
{
Pos = P;
}
Minion::~Minion()
{
//dtor
}
Position getPos()
{
return Pos;
}
This is my Minion.h file:
#ifndef MINION_H
#define MINION_H
#include "../include/Position.h"
class Minion
{
public:
Minion(Position);
virtual ~Minion();
float getPos();
void Draw();
protected:
private:
Position Pos;
double health;
};
#endif // MINION_H
And this is my Position structure that I am going to be using globaly and passing as variables to a lot of functions:
#ifndef POSITION_H_INCLUDED
#define POSITION_H_INCLUDED
struct Position{
float Xpos;
float Ypos;
};
#endif // POSITION_H_INCLUDED