Object does not name a type. Declared in the same header
So I have created a class. And declared an array of objects based on it.
When running the program I get the message
"room does not name a type"
I have no idea why this won't work. If I put it in the main it works fine.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
#ifndef ROOMS_H
#define ROOMS_H
#include <stdint.h>
class rooms
{
private:
std::vector<std::vector<int> > layout;
int x;
public:
void setLayout(std::vector<std::vector<int> > newLayout)
{
layout = newLayout;
}
void setX(int newX)
{
x = newX;
}
};
rooms room[10];
room[0].setX(5);
#endif
|
Any help is much appreciated. Thanks
You need it to be in main.
lines 28 and 30 shouldn't be floating around globally like that.
Topic archived. No new replies allowed.