A problem with vectors

I'm trying to create a small "roguelike" game with C++. I'm using a vector to store all objects so they are easier to draw. However I have a little problem. This is the part of the code that doesn't work:

1
2
3
4
5
6
7
8
9
10
#include <curses.h>
#include <vector>
#include "object.h"

std::vector<Object> objectlist;

Object player (20, 10, '@', 1);
Object testnpc (15, 15, '@', 2);

objectlist.push_back (testnpc);


And the error is:

object.cpp:10:1: error: ‘objectlist’ does not name a type

Hopefully someone can help :)
You can't have arbitrary code outside a function, so you'll need to do something about the push_back.
Thanks, I put it inside a function and it works now :)
Topic archived. No new replies allowed.