I’m defining a C++ header file, and for some reason the class I’m creating gives an error when I try to refer to a struct which is defined in the very same file, along with an enumeration class I created.
I’m pretty to new to C++, though I have some experience with Java and C#. Even then, my programming experience is relatively low. Am I initializing the reference wrong? Should I be placing both the struct and the enum in a separate header file?
#include <iostream>
#include <stdio.h>
class Character
{
private:
Stats stats; //<--error: "Type 'Stats' could not be resolved."
public:
};
struct Stats
{
int strength;
int intelligence;
int endurance;
int speed;
int agility;
int luck;
};
enum Race
{
NONE,
HUMAN,
ALIEN,
ANDROID
};
Note: I’m using Eclipse 3.7 (Indigo) for C++, in case that means anything.
C++ is parsed from the top of the file to the bottom; you need to move your
Statsclass definition to above yourCharacterclass definition.