When I build my project, I get these errors -
Code:
/home/sterling/CODE/Dormitory/Hallway.h|51|error: redefinition of ‘int& Hallway::getAvaL()’|
/home/sterling/CODE/Dormitory/Hallway.h|42|error: ‘int& Hallway::getAvaL()’ previously defined here|
/home/sterling/CODE/Dormitory/Hallway.h|56|error: redefinition of ‘int& Hallway::getAvaW()’|/home/sterling/CODE/Dormitory/Hallway.h|43|error: ‘int& Hallway::getAvaW()’ previously defined here|
I don't understand how the functions are being redefined. My .h and .cpp are -
Code:
#ifndef HALLWAY_H
#define HALLWAY_H
#include "Bathroom.h"
#include "Bedroom.h"
class Hallway {
public:
Hallway();
~Hallway();
const int& getLength();
const int& getWidth();
void setAvaL(int&);
int& getAvaL();
void setAvaW(int&);
int& getAvaW();
std::vector<Bathroom>& getBathrooms();
std::vector<Bedroom>& getBedrooms();
void addBedroom(Bedroom&);
void addBathroom(Bathroom&);
private:
std::vector<Bedroom> bedrooms;
std::vector<Bathroom> bathrooms;
const int length;
const int width;
int avaL;
int avaW;
};
#endif
Code:
#include "Hallway.h"
Hallway::Hallway()
: length(300), width(100) {}
Hallway::~Hallway() {}
const int& Hallway::getLength() {return length;}
const int& Hallway::getWidth() {return width;}
int& Hallway::getAvaL() {return avaL;}
int& Hallway::getAvaW() {return avaW;}
std::vector<Bathroom>& Hallway::getBathrooms() {return bathrooms;}
std::vector<Bedroom>& Hallway::getBedrooms() {return bedrooms;}
void Hallway::setAvaL(int& l) {
avaL = l;
}
int& Hallway::getAvaL() {return avaL;}
void Hallway::setAvaW(int& w) {
avaW = w;
}
int& Hallway::getAvaW() {return avaW;}
Not sure what else to say about it other than I just don't get at all how they are being redefined...can anyone help me out? I have other classes in the project which I can share if they are needed. But they all compile fine.