Using classes defined later in the same file?
by Daniel Buckmaster · in Torque Game Engine Advanced · 08/22/2009 (1:27 am) · 2 replies
I'm working on adding stances to Player, and I want to store the stance enum in the Player class. But if I do this:
struct PlayerData {
F32 maxForwardSpeeds[Player::NumStances];
};
class Player {
enum Stance {
NumStances
};
};I get a compiler error 'use of undefined type Player'. Can I solve this? Or do I need to use a static enum?About the author
Studying mechatronic engineering and computer science at the University of Sydney. Game development is probably my most time-consuming hobby!
#2
Google tells me that C++ doesn't support forward declaration of enums - could that be my problem?
I've solved the problem temporarily by doing this at the top of the header file:
08/22/2009 (3:06 am)
Still get the same error, unfortunately. That seems like it should have worked... Do I need to clean and rebuild or something?Google tells me that C++ doesn't support forward declaration of enums - could that be my problem?
I've solved the problem temporarily by doing this at the top of the header file:
namespace PlayerStances {
enum {
NumStances
};
};Then just referring to PlayerStances::value whenever I need to.
Torque Owner Shaderman
Just put the single line
above the struct.