Sign in to follow this  
gapern

vector not recognizing its type?

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
#ifndef ALLTHINGS_H
#define 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;
allthings.push_back(tree1);
allthings.push_back(bush1);
allthings.push_back(crown);
allthings.push_back(separator);
allthings.push_back(tree2);
allthings.push_back(bush2);

#endif
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

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