Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7694841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:24:37+00:00 2026-05-31T21:24:37+00:00

I am writing a program for class that manages a Hotel. This Report1 function

  • 0

I am writing a program for class that manages a Hotel. This Report1 function is supposed to list all the occupied rooms and which customer is in each room. I have the code written, but i am getting a error in the condition statement of my nested FOR loop. The compiler is underlining iRoom in the loop………… for(int j = 0; j < iRoom.customerIDinRoom…..it is saying the iRoom expression must have a class type, but I gave it a class type when I declared it in the first FOR loop(of type Room). Any suggestioins?

string Hotel::Report1()
{

string result;
for(int i=0;i<listofrooms.size();i++)
{
    Room iRoom = listofrooms.get(i);
    result+= padLeft(intToString(iRoom.roomID),' ',8)+" "+
        padRight(iRoom.name,' ',20) + " "+
        padLeft(intToString(iRoom.floor),' ',8) + " " +
        padLeft(intToString(iRoom.number),' ',8) + " " +
        padLeft(intToString(iRoom.basePriceInSeason),' ',8) + " " +
        padLeft(intToDollarString(iRoom.basePriceOutOfSeason),' ',8) + "\n";

    for(int j = 0; j < iRoom.customerIDinRoom.size(); j++)
    {
        int cusID= iRoom.customerIDinRoom[j];
        Customer & cus = listofcustomers.getByID(cusID);
        result+= padLeft(intToString(cus.customerID),' ',18)+" "+
            padRight(cus.name,' ',20) + " "+
            padRight(cus.phoneNumber,' ',10) + " " +
            padRight(cus.ccNumber,' ',20) + "\n";

    }
}
return result;
}

This is the Room class declaration

#include <iostream>
#include <string>
using namespace std;

class Hotel;

class ListOfRooms;

class Room
{
friend class ListOfRooms;
friend class Hotel;
public:
Room(string n,int flo,int num,int bpin, int bpos);
Room();
void addCusID(int cusID){customerIDinRoom = cusID;}
void removeCustomerID(int cusID) { customerIDinRoom = 0;}

private:
string name; //BUILDING
int floor;
int number;
int basePriceInSeason;
int basePriceOutOfSeason;
int roomID;
int customerIDinRoom; //not pushback, will be assignment
};
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T21:24:38+00:00Added an answer on May 31, 2026 at 9:24 pm

    The error is that customerIDInRoom is an int, but you are calling a size method on it. If you are trying to loop from 0 to customerIDInRoom-1 then you can simply remove the size() call. If you need to keep a range of customerIDInRoom ints (as suggested by your “no pushback” comment in the code), then you would most likely need a standard library container. Which one to use depends on your requirements. All of these have a size() method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a program for a class that is very simple. All it
I am writing a program that manages a bunch of timers. The user has
I am writing a program for class that is asking us to create a
I'm writing a logging class that uses a templatized operator<< function. I'm specializing the
I'm fairly new to Qt. This is my second 'real' program that I'm writing.
I am writing a program that starts another java process which runs certain code.
I'm writing a program for my visual basic class that computes the prices of
I am writing a c program for a class that is a small shell.
I am writing a program in C# that needs to support undo/redo. For this
I'm writing a C++ program for class that requires a set of N child

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.