Nov 20, 2010 at 3:57pm UTC
I am generating a hotel program and iam doing it in steps.....very new to c++
this is what i have so far;
my problem is when i call the function Get_Rate it giving errors. Love if any one could help
# include <iostream>
# include <iomanip>
using namespace std;
class HotelRoom
{
private:
int rm_num;
int rm_cap;
int rm_status;
double drate;
public:
HotelRoom ();
void SetRm_Number(int);
void SetRm_Capacity(int);
void SetRm_Status(int);
void SetRm_Rate(double);
int Get_Number(int);
int Get_Capacity(int);
int Get_Status(int);
double Get_Rate(double);
};
void HotelRoom::SetRm_Number(int num)
{
num = rm_num;
}
void HotelRoom::SetRm_Capacity(int cap)
{
cap = rm_cap;
cap == 0;
cout<< cap;
}
void HotelRoom::SetRm_Status(int status)
{
status = rm_status;
}
void HotelRoom::SetRm_Rate(double rate)
{
rate = drate;
}
int HotelRoom::Get_Number(int _rmnumber)
{
return _rmnumber;
}
int HotelRoom::Get_Capacity(int _rmcapacity)
{
return _rmcapacity;
}
int HotelRoom::Get_Status(int _rmstatus)
{
return _rmstatus;
}
double HotelRoom::Get_Rate(double _rrate)
{
_rrate = 12;
return _rrate;
}
main ()
{
HotelRoom hotel;
hotel.Get_Rate(13);
cout<< Get_Rate()<< endl<< endl;
system ("pause");
return EXIT_SUCCESS;
Nov 20, 2010 at 4:07pm UTC
Get_rate() function
can not call this way
should call or through pointer or object
as follows
HotelRoom *p;
p->Get_Rate(3.4);
or
HotelRoom n;
n.Get_Rate(3.4);
Last edited on Nov 20, 2010 at 4:10pm UTC
Nov 20, 2010 at 4:19pm UTC
when I do hotel.Get_Rate(12) it gives a linker error
Nov 20, 2010 at 4:23pm UTC
this also gives a linker error
HotelRoom *p;
p->Get_Rate(3.4);
Nov 20, 2010 at 4:55pm UTC
thanks firix and null.....Is it possible for you to explain the use of constructor and how they are used.
I am seeing it being proposed but i guess i had it wrong in my program.