Sign in to follow this  
Antonym

Crazy error

Recommended Posts

\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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
I feel like such an enormous retard right now, the problem was so simple, I was trying to declare objects of type stats with another object of type stats. As for why I need that well it's a long story ;). Send me a pm we can be buddies.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this