• Advertisement
Sign in to follow this  

Crazy error

This topic is 3386 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement