Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Why am I getting an error

$
0
0
We are practicing friend functions this week. It seemed pretty easy when we were studying this but when I tried to compile it, it gave me an error and I have tried tweaking it but I am still at a lost.


//Lynette Wilkins
//Week 11
//Program that transers a guest from one room to another room

//Lynette Wilkins
//Week 8
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

class HotelRoom
{
	friend int Transfer(HotelRoom&, HotelRoom&);
private:
	char room_num[3]; //Character array that stores a 3-character room number
	char transroom_num;
	char* guest; //Character pointer,which stores the name of the guest occupying the room
	int room_cap;
	int occup_stat;
	double daily_rt;
	int tranfer_room;

public:
	HotelRoom(char room[], char* g_p, int roomcap, int occup, double rate = 89.00);
	~HotelRoom();
	void Display_Number();  //Displays room number and add the method Display_Guest()
	int Get_Capacity();
	int Get_Status();
	double Get_Rate();
	int Change_Status(int);
	double Change_Rate(double);
	void Display_Guest();

};

HotelRoom::HotelRoom(char room[], char* g_p, int roomcap,int occup, double rate )
{
	strcpy(room_num, room); //copy first argument into room_num[]
	guest = new char[strlen(g_p) + 1]; //reserve space for the guest name
	strcpy(guest, g_p); //copy fourth argument into new space
    room_cap = roomcap;
	daily_rt = rate;
	occup_stat = occup;

}

HotelRoom::~HotelRoom()
{
	cout << endl<<endl;
	cout << "Guest in room "<<room_num << " has checked out." <<endl;
	delete [] guest;
}

 void HotelRoom::Display_Number()
{
	cout << room_num;
}

int HotelRoom::Get_Capacity()
{
	return room_cap;
}

int HotelRoom::Get_Status()
{
	
	return occup_stat;
}



int HotelRoom::Change_Status(int occup)
{
	occup_stat = occup;

	if (occup > room_cap)
	{
		return -1;
	}
	else
	
	return occup_stat;
	
}

double HotelRoom::Get_Rate()
{
	return daily_rt;
}

double HotelRoom::Change_Rate(double rate)
{
	daily_rt = rate;
		return daily_rt;
}

int Transfer(char room, char transroom)

{
	

	room = transroom;
	return room;
}

void HotelRoom::Display_Guest()
{
	cout<< guest;
}
int main()
{
	cout<< setprecision(2)
		<<setiosflags(ios::fixed)
		<<setiosflags(ios::showpoint);
	
char room[4]; 
char buffer[100]; //temporarily stores guest name
int roomcap = 4;
char transroom[4];
int occup;
double rate = 89.00;


cout<<"\nEnter the room number: "<<endl;
cin.getline(room, 5);

cout<<"\nEnter the amount of guest to occupy this room: "<<endl;
cin>>occup;


cout<<"\nEnter the primary guest name: "<<endl;
cin.ignore();
cin.getline(buffer, 100);

cout<<"\nThe guest has decided to transfer rooms"<<endl;
cout<<"\nEnter the room to transfer the guest to"<<endl;
cin.getline(transroom,5);

HotelRoom room1(room, buffer, roomcap, occup, rate); //initialize the object

if (room1.Change_Status(occup) == -1)
{
	cout<<"You have exceeded the room capacity"<<endl;
}
else
{

cout <<"\nThe room number is ";
room1.Display_Number();
cout<<"."<<endl;
cout<<"\nThe name of the primary guest is ";
room1.Display_Guest();
cout <<"."<<endl;
cout<<"\nThe number of guest in the room is "<<room1.Change_Status(occup)<<"."<<endl;
cout<<"\nThe daily rate for room "<<room<< " is "<<room1.Get_Rate()<<"."<<endl<<endl;

cout<<"\nYou have tranferred the guest from room"<<room1.Display_Number()<<"to"<<Transfer(room, transroom)<<endl;
}





cout<<"\nRoom ";
room1.Display_Number();
cout<<" is vacant."<<endl;





system("PAUSE");

	
	return 0;
}




The error is saying

"(159): error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'void' (or there is no acceptable conversion)"

Any help would be greatly appreciated.

Thanks in advance!!

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>