Crazy error
\visual studio 2005\projects\mud\mud\main.cpp(11) : error C2146: syntax error : missing ';' before identifier 'HP'
\visual studio 2005\projects\mud\mud\main.cpp(11) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
\visual studio 2005\projects\mud\mud\main.cpp(11) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int'
#include <iostream>
using namespace std;
struct stats{
float HP;
}stats;
struct character{
stats HP;
};
Why is it giving me the above error messages? I don't see anything wrong, that's all the code there is by the way so the error must be there. It's driving me insane.
struct stats{float HP;}stats;
This defines a structure named 'stats', and an object of type 'stats' which is also named 'stats'. From then on, the name 'stats' refers to the object, not the type. Therefore, you cannot write stats HP; (although you could resolve the ambiguity with struct stats HP;).On the other hand, why do you need an object named 'stats' at all?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement