Hi to all! I'm writing a simple simulation program for elevators but i get a problem, namely:
elevator.cpp: In constructor `Elevator::Elevator(int)':
elevator.cpp:41: error: no matching function for call to `Button::Button()'
elevator.cpp:10: note: candidates are: Button::Button(const Button&)
elevator.cpp:16: note: Button::Button(int, bool)
elevator.cpp:41: error: no matching function for call to `Button::Button()'
elevator.cpp:10: note: candidates are: Button::Button(const Button&)
elevator.cpp:16: note: Button::Button(int, bool)
elevator.cpp:44: error: `Buttonset' undeclared (first use this function)
elevator.cpp:44: error: (Each undeclared identifier is reported only once for each function it appears in.)
elevator.cpp:45: error: no match for 'operator=' in '((Elevator*)this)->Elevator::Alert = (((Button*)operator new(8u)), (<anonymous>->Button::Button(3, 0), <anonymous>))'
elevator.cpp:10: note: candidates are: Button& Button::operator=(const Button&)
The code that produces this minor irritation is the constructor of the 2nd class:
class Button {
private:
enum Types {inside, outside, alarm};
Types type;
bool active;
public:
Button(int typ, bool state) {
if (typ!=1 && typ!=2 && typ!=3)
throw ("Crappy button type in initialisation...Terminating.");
if(state!=0 && state!=1)
throw("Boolean expected in button class initialisation... Terminating.");
type = Types(typ-1);
active = state;
}
inline bool is_active(void) { return active; };
inline int who(void) { return type; };
inline void flashb(void) { active=!active; };
inline void press(void) { active = 1; };
};
class Elevator {
private:
int number;
Button ButtonSet[10];
Button Alert;
queue<int> queue;
int last_stop;
enum Status { moving, idle, alert };
Status stats;
public:
Elevator(int num) {
number = num;
for(int i=0; i<10; i++)
Buttonset[i] = new Button(1, 0);
Alert = new Button(3, 0);
stats = Status(1);
};
void pressb (int num);
void emergency(void);
inline void set_stats(int status) { stats = Status(status-1); } ;
inline int get_stats(void) { return (int)stats; };
int move(void);
};
I would be thankful if somebody shares an idea of the possible error!