Computing.Net > Forums > Programming > my program can't compile.I'm using Visual

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

my program can't compile.I'm using Visual

Reply to Message Icon

Name: khukhu
Date: July 4, 2009 at 09:41:43 Pacific
OS: Windows XP
Subcategory: C/C++
Comment:

#include <iostream>
#include <string>
using namespace std;
//class TRAVEL CONTROLS ALL FUNCTIONS
class Travel
{

struct Hotel
{ string cityName;
string hotelName;
int hotelCode;
int standardRoomNo;
int standardRoomPrice;
int deluxeRoomNo;
int deluxeRoomPrice;
}H;

struct Resort
{ string cityName;
int resortID;
string resortName;
int numberOfResorts;
int resortPrice;
}R;
struct Booking
{ int reservationNum;
string clientName;
int contactTel;
string email;
char option;
}B;

public:
void Hotelinput();
void Resortinput();
void Bookinginput();
void Display1();
void Display2();
void Display3();
} P;


//**********************************************************
// FUNCTION NAME : Hotel
//**********************************************************

void Travel::Hotelinput()
{
//DATA OF HOTEL
cout<<"Enter Hotel Information:";
cout<<"Enter City Name:";
cin>>(H.cityName);
cout<<"Hotel Name:";
cin>>(H.hotelName);
cout<<"Hotel Code:";
cin>>(H.hotelCode);
cout<<"Standard Room Number:";
cin>>(H.standardRoomNo);
cout<<"Standard Room Price:";
cin>>(H.standardRoomPrice);
cout<<"Deluxe Room Number:";
cin>>(H.deluxeRoomNo);
cout<<"Deluxe Room Price:";
cin>>(H.deluxeRoomPrice);
}

void Travel::Resortinput()
//DATA OFRESORT
{ cout<<"Enter City Name:";
cin>>(R.cityName);
cout<<"Enter Resort ID:";
cin>>(R.resortID);
cout<<"Enter Resort Name:";
cin>>(R.resortName);
cout<<"Number Of Resorts:";
cin>>(R.numberOfResorts);
cout<<"Enter Resort Price:";
cin>>(R.resortPrice);
}

void Travel::Bookinginput()
//BOOKING DATA
{ cout<<"Enter Reservation Number:";
cin>>(B.reservationNum);
cout<<"Enter Client Name:";
cin>>(B.clientName);
cout<<"Enter Contact Tel.:";
cin>>(B.contactTel);
cout<<"Enter E-mail:";
cin>>(B.email);
cout<<"Enter Catergory(H for Hotel,R forResort):";
cin>>(B.option);
}

void Travel::Display1()
{
cout<<"Hotel information:";
cout<<"City Name:"<<H.cityName<<endl;
cout<<"Hotel Name:"<<H.hotelName<<endl;
cout<<"Hotel Code:"<<H.hotelCode<<endl;
cout<<"Standard Room Number:"<<H.standardRoomNo<<endl;
cout<<"Standard Room Price:"<<H.standardRoomPrice<<endl;
cout<<" Deluxe Room Number:"<<H.deluxeRoomNo<<endl;
cout<<"Deluxe Room Price:"<<H.deluxeRoomPrice<<endl;

}

void Travel::Display2()
{
cout<<"Resort information:"<<endl;
cout<<"City Name:"<<R.cityName<<endl;
cout<<"Resort Name:"<<R.resortName<<endl;
cout<<"Resort ID:"<<R.resortID<<endl;
cout<<"Resort Price:"<<R.resortPrice<<endl;

}

void Travel::Display3()
{
cout<<"Reservation Number:"<<B.reservationNum<<endl;
cout<<"Client Name:"<<B.clientName<<endl;
cout<<"Contact Tel.:"<<B.contactTel<<endl;
cout<<"E-mail:"<<B.email<<endl;
cout<<"Catergory:"<<B.option<<endl;
}

int main()
{
struct Travel::Hotel Hot_1;
void displayMain();
return 0;
}
void displayMain()
{
{int selection;
do
{
cout<<"**********MAIN**********"<<endl;
cout<<"1.) Add Hotel Information: " << endl;
cout<<"2.) Add Resort Information:" << endl;
cout<<"3.) Add New Booking:" << endl;
cout<<"4.) View Hotel Information:"<<endl;
cout<<"5.) View Resort Information:"<<endl;
cout<<"6.) View Booking Information:"<<endl;
cout<<"7.) EXIT" << endl;
cout << "Selection: ";
cin >> selection;
}
while (selection <= 0 && selection >= 7);

switch (selection)
{
case 1:
P.Hotelinput();
break;
case 2:
P.Resortinput();
break;
case 3:
P.Bookinginput();
break;
case 4:
P.Display1();
case 5:
P.Display2();
case 6:
P.Display3();

case 7://leave blank
default:
;
}
}
}



Sponsored Link
Ads by Google

Response Number 1
Name: Razor2.3
Date: July 4, 2009 at 09:50:51 Pacific
Reply:

Without throwing it into a complier, VS doesn't use int main(). It uses int _tmain(int argc, _TCHAR* argv[])

EDIT after throwing it into VC++:

struct Travel::Hotel Hot_1;

In your main function, you attempt to make a copy of a struct you defined as private to class Travel. You cannot do this.

0

Response Number 2
Name: khukhu
Date: July 4, 2009 at 10:24:01 Pacific
Reply:

Razor2.3 thank you for your answer.I am still new to programming......so i am failing to understand how to go about it.As for attempting to make a copy of a struct i defined as private to class Travel in the main function I got it.


0

Response Number 3
Name: Razor2.3
Date: July 4, 2009 at 12:30:25 Pacific
Reply:

Step 1: Change the main()'s definition as I said in my previous post.

Step 2: Get rid of the line struct Travel::Hotel Hot_1; in your main function. You don't need it, and you never do anything with it.

Step 3: Just below that line, strip the void off of the line below that.

Step 4: Move the entire main function below the displayVoid() function.

Step 4 Alt: Before the main function, add the following line:

void displayMain();


0

Response Number 4
Name: khukhu
Date: July 4, 2009 at 19:30:27 Pacific
Reply:

thank you once again Razor2.3.Now the problem is that the program can't be executed.When i compile there are no errors.


0

Response Number 5
Name: khukhu
Date: July 5, 2009 at 02:37:43 Pacific
Reply:

Hi...the program is now executable.Now how do i enter and display information for different(several) hotels,resorts and clients?
#include <iostream>
#include <string>
using namespace std;
//class TRAVEL CONTROLS ALL FUNCTIONS
class Travel
{

struct Hotel
{ string cityName;
string hotelName;
int hotelCode;
int standardRoomNo;
int standardRoomPrice;
int deluxeRoomNo;
int deluxeRoomPrice;
}H;

struct Resort
{ string cityName;
int resortID;
string resortName;
int numberOfResorts;
int resortPrice;
}R;
struct Booking
{ int reservationNum;
string clientName;
int contactTel;
string email;
char option;
}B;

public:
void Hotelinput();
void Resortinput();
void Bookinginput();
void Display1();
void Display2();
void Display3();
} P;


//**********************************************************
// FUNCTION NAME : Hotel
//**********************************************************

void Travel::Hotelinput()
{
//DATA OF HOTEL
cout<<"Enter Hotel Information:";
cout<<"Enter City Name:";
cin>>(H.cityName);
cout<<"Hotel Name:";
cin>>(H.hotelName);
cout<<"Hotel Code:";
cin>>(H.hotelCode);
cout<<"Standard Room Number:";
cin>>(H.standardRoomNo);
cout<<"Standard Room Price:";
cin>>(H.standardRoomPrice);
cout<<"Deluxe Room Number:";
cin>>(H.deluxeRoomNo);
cout<<"Deluxe Room Price:";
cin>>(H.deluxeRoomPrice);
}

void Travel::Resortinput()
//DATA OFRESORT
{ cout<<"Enter City Name:";
cin>>(R.cityName);
cout<<"Enter Resort ID:";
cin>>(R.resortID);
cout<<"Enter Resort Name:";
cin>>(R.resortName);
cout<<"Number Of Resorts:";
cin>>(R.numberOfResorts);
cout<<"Enter Resort Price:";
cin>>(R.resortPrice);
}

void Travel::Bookinginput()
//BOOKING DATA
{ cout<<"Enter Reservation Number:";
cin>>(B.reservationNum);
cout<<"Enter Client Name:";
cin>>(B.clientName);
cout<<"Enter Contact Tel.:";
cin>>(B.contactTel);
cout<<"Enter E-mail:";
cin>>(B.email);
cout<<"Enter Catergory(H for Hotel,R forResort):";
cin>>(B.option);
}

void Travel::Display1()
{
cout<<"Hotel information:";
cout<<"City Name:"<<H.cityName<<endl;
cout<<"Hotel Name:"<<H.hotelName<<endl;
cout<<"Hotel Code:"<<H.hotelCode<<endl;
cout<<"Standard Room Number:"<<H.standardRoomNo<<endl;
cout<<"Standard Room Price:"<<H.standardRoomPrice<<endl;
cout<<" Deluxe Room Number:"<<H.deluxeRoomNo<<endl;
cout<<"Deluxe Room Price:"<<H.deluxeRoomPrice<<endl;

}

void Travel::Display2()
{
cout<<"Resort information:"<<endl;
cout<<"City Name:"<<R.cityName<<endl;
cout<<"Resort Name:"<<R.resortName<<endl;
cout<<"Resort ID:"<<R.resortID<<endl;
cout<<"Resort Price:"<<R.resortPrice<<endl;

}

void Travel::Display3()
{
cout<<"Reservation Number:"<<B.reservationNum<<endl;
cout<<"Client Name:"<<B.clientName<<endl;
cout<<"Contact Tel.:"<<B.contactTel<<endl;
cout<<"E-mail:"<<B.email<<endl;
cout<<"Catergory:"<<B.option<<endl;
}


void displayMain();
int main()
{
displayMain();
return 0;
}
void displayMain()
{
{int selection;
do
{
cout<<"**********MAIN**********"<<endl;
cout<<"1.) Add Hotel Information: " << endl;
cout<<"2.) Add Resort Information:" << endl;
cout<<"3.) Add New Booking:" << endl;
cout<<"4.) View Hotel Information:"<<endl;
cout<<"5.) View Resort Information:"<<endl;
cout<<"6.) View Booking Information:"<<endl;
cout<<"7.) EXIT" << endl;
cout << "Selection: ";
cin >> selection;
}
while (selection <= 0 && selection >= 7);

switch (selection)
{
case 1:
P.Hotelinput();
break;
case 2:
P.Resortinput();
break;
case 3:
P.Bookinginput();
break;
case 4:
P.Display1();
case 5:
P.Display2();
case 6:
P.Display3();

case 7://leave blank
default:
;
}
}
}


0

Related Posts

See More



Response Number 6
Name: Razor2.3
Date: July 5, 2009 at 05:34:52 Pacific
Reply:

You need to either:

A: Wrap your menu and your select case in a loop

B: Have your displayMain() return the value of your selection, and place the loop in your main() function.


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: my program can't compile.I'm using Visual

external arrays in c++ www.computing.net/answers/programming/external-arrays-in-c/2919.html

My first VB project, and I'm stuck. www.computing.net/answers/programming/my-first-vb-project-and-im-stuck/2434.html

Scheduled Tasks and VBS Scripts www.computing.net/answers/programming/scheduled-tasks-and-vbs-scripts/18801.html