Advertisement Jump to content
Sign in to follow this  

vector not recognizing its type?

This topic is 3830 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

I've got a vector off in it's own file and i'm filling it with objects of my thing class. Here's the entire header file. allthings.h

#include "classes.h" //this is where my thing class is stored
#include "things.h" //this is where my objects of the thing class are stored
#include <vector>
#include <string>

using namespace std;

vector<thing> allthings;

Here are my errors.
error C2143: syntax error : missing ';' before '.'

error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

error C2371: 'allthings' : redefinition; different basic types
Error #2 looks like it cannot recognize my thing class. But i've got that header file included. It's in classes.h. My objects are in things.h. Error #1 looks like it's related to error #2. Error #3 is weird. I do NOT have my allthings vector defined anywhere else in my code. All of my headers have inclusion guards also, so that shouldn't be the culprit. Note that these errors are repeated on every single push_back line. My vector DOES work if I have it in the file I want to use it in, which is adventure.cpp. But I have it in a separate file for a reason. I want to keep everything except the main game loop out of adventure.cpp. I'm assuming this has something to do with me needing a pointer somewhere, but I do not know where. Is it a pointer problem or is there something else that could be causing this? I have done everything I can think of and nothing has worked, so I really need some help here please.

Share this post

Link to post
Share on other sites
Not only that, but your compiler won't like it when ANY non-assignment statement is in global scope. If you could do things like this in global space, what would be the point of int main()?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!