same here i do that all the time... sometimes i include homemade header files like this
#include <homemade.h>
anyway i need help. I made it a bit bigger and everything is fine only when i run it it doesn't show me the result i was expecting.
Main.cpp:
Code:
#include <iostream>
#include <stdlib.h>
#include "alarm.h"
void make(int, int, int);
int main(int argc, char *argv[])
{
Alarm comp(4, BURGLAR, COMPUTER);
//here burglar is supposed to be '1'
cout<<comp.getType()<<endl;
make(comp.getAmount(), comp.getType(), comp.getRoom());
Alarm kit(2, FIRE, KITCHEN);
//and fire '0'
cout<<kit.getType()<<endl;
make(kit.getAmount(), kit.getType(), kit.getRoom());
system("PAUSE");
return 0;
}
void make(int amount, int type, int room)
{
cout<<amount<<" ";
switch(type)
{
case 0:
cout<<"fire";
break;
case 1:
cout<<"burglar";
break;
case 2:
cout<<"window";
break;
}
cout<<" alarms where installed in the ";
switch(room)
{
case 0:
cout<<"kitchen.";
break;
case 1:
cout<<"living room.";
break;
case 2-4:
cout<<"bed room.";
break;
case 5:
cout<<"computer room.";
break;
case 6-7:
cout<<"bathroom.";
break;
}
cout<<"\n";
}
alarm.h:
Code:
#ifndef ALARM_H
#define ALARM_H
#include <iostream.h>
enum TYPE {FIRE, BURGLAR, WINDOW};
enum ROOM {KITCHEN, LIVING, BED1, BED2, BED3, COMPUTER, BATH1, BATH2};
class Alarm
{
public:
Alarm();
Alarm(int amount, TYPE type, ROOM room);
~Alarm();
ROOM getRoom() {return theRoom;}
int getAmount() {return theAm;}
TYPE getType() {return itsType;}
private:
int theAm;
TYPE itsType;
ROOM theRoom;
};
Alarm::Alarm()
{
}
Alarm::Alarm(int amount, TYPE type, ROOM room)
{
theAm = amount;
itsType = BURGLAR;
theRoom = room;
}
Alarm::~Alarm()
{
}
#endif
for the enum TYPE all the values are one.(this is how i display them on the screen they all have a differnt value starting from 0 but i guess you allready knew that.)
anyway it says that WINDOW BURGLAR and FIRE are all one making it come out wrong in the program.