I have a .h and .cpp for a Room object. Each Room object should contain a vector of Window objects. When I build the project I get these compiler errors -
Code:
1>c:\users\sterling\documents\visual studio 2008\projects\bathroom\bathroom\room.h(23) : error C2143: syntax error : missing ';' before '<'
1>c:\users\sterling\documents\visual studio 2008\projects\bathroom\bathroom\room.h(23) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\sterling\documents\visual studio 2008\projects\bathroom\bathroom\room.h(23) : error C2238: unexpected token(s) preceding ';'
1>c:\users\sterling\documents\visual studio 2008\projects\bathroom\bathroom\room.h(34) : error C2143: syntax error : missing ';' before '<'
1>c:\users\sterling\documents\visual studio 2008\projects\bathroom\bathroom\room.h(34) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\sterling\documents\visual studio 2008\projects\bathroom\bathroom\room.h(34) : error C2238: unexpected token(s) preceding ';'
1>c:\users\sterling\documents\visual studio 2008\projects\bathroom\bathroom\room.cpp(32) : error C2143: syntax error : missing ';' before '<'
1>c:\users\sterling\documents\visual studio 2008\projects\bathroom\bathroom\room.cpp(32) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\sterling\documents\visual studio 2008\projects\bathroom\bathroom\room.cpp(32) : error C2039: 'getWindowVec' : is not a member of 'Room'
1> c:\users\sterling\documents\visual studio 2008\projects\bathroom\bathroom\room.h(10) : see declaration of 'Room'
1>c:\users\sterling\documents\visual studio 2008\projects\bathroom\bathroom\room.cpp(32) : error C2143: syntax error : missing ';' before '{'
1>c:\users\sterling\documents\visual studio 2008\projects\bathroom\bathroom\room.cpp(32) : error C2447: '{' : missing function header (old-style formal list?)
1>c:\users\sterling\documents\visual studio 2008\projects\bathroom\bathroom\room.cpp(38) : error C2228: left of '.push_back' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\sterling\documents\visual studio 2008\projects\bathroom\bathroom\room.cpp(38) : error C3861: 'getWindowVec': identifier not found
1>c:\users\sterling\documents\visual studio 2008\projects\bathroom\bathroom\room.cpp(43) : error C2228: left of '.push_back' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\sterling\documents\visual studio 2008\projects\bathroom\bathroom\room.cpp(43) : error C3861: 'getWindowVec': identifier not found
1>c:\users\sterling\documents\visual studio 2008\projects\bathroom\bathroom\room.cpp(47) : error C2228: left of '.push_back' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\sterling\documents\visual studio 2008\projects\bathroom\bathroom\room.cpp(47) : error C3861: 'getWindowVec': identifier not found
Here are the .h and .cpp files
Code:
#include <vector>
#include "Window.h"
#pragma once
#ifndef ROOM_H
#define ROOM_H
class Room
{
public:
Room(void);
Room(int, int);
~Room(void);
int getLength();
int getWidth();
void turnLightsOn();
void turnLightsOff();
bool areLightsOn();
vector<Window>& getWindowVec();
void addWindow();
void addWindow(int, int);
void addWindow(Window aWindow);
private:
int length;
int width;
bool lightsOn;
vector<Window> windowVec;
};
#endif
Code:
#include "Room.h"
Room::Room(void)
: length(80), width(80){}
Room::Room(int l, int w)
: length(l), width(w) {}
Room::~Room(void)
{}
int Room::getLength() {
return length;
}
int Room::getWidth() {
return width;
}
void Room::turnLightsOn() {
lightsOn = true;
}
void Room::turnLightsOff() {
lightsOn = false;
}
bool Room::areLightsOn() {
return lightsOn;
}
vector<Window>& Room::getWindowVec() {
return windowVec;
}
void Room::addWindow() {
Window aWindow;
getWindowVec().push_back(aWindow);
}
void Room::addWindow(int l, int w) {
Window aWindow(l, w);
getWindowVec().push_back(aWindow);
}
void Room::addWindow(Window aWindow) {
getWindowVec().push_back(aWindow);
}
I don't see where I am missing semi-colons as the compiler indicates. But maybe it's something else I am not aware of. Can anyone help me out?