Hello!
I am getting an error message of "Possible use of 'charSeatFull' before definition in function main(). I looked at the particular char and I don't refer it before the call only when I declare it. I don't understand of why could there be a possible use of before the function main.
Your help is appreciated.
#include <iostream.h>
#include <iomanip.h>
#include <cstring.h>
//=========================================================
class clFlight
{private:
int firstclasscnt;
int economycnt;
char charSection;
public:
clFlight();
int chkSection();
int assignSeat();
};
clFlight::clFlight()
{firstclasscnt = 0;
economycnt = 5;}
int clFlight::chkSection()
{char charReply;
cout << "/nPlease select 1 First Class or 2 Economy: ";
cin >> charSection;
if (charSection == '1'){
if (firstclasscnt < 5){
return 1;
} else {
cout << "/nFirst Class Section is Full. "
<< "/nWould you like the Economy Section instead?"
<< "/nPlease select Y or N: ";
cin >> charReply;
if (charReply == 'Y' || charReply == 'N' ||
charReply == 'y' || charReply == 'n') {
if (charReply == 'Y' || charReply == 'y') {
return 2;
} else {
cout << "/n================================"
<< "/n=The next flight will be in 3 hours.="
<< "/n============================";
return 0; }}}};
if (charSection == '2') {
if (economycnt < 10) {
return 2;
} else {
cout << "/nEconomy Section is Full. "
<< "/nWould you like the First Class Section instead?"
<< "/nPlease Select Y or N: ";
cin >> charReply;
if (charReply == 'Y' || charReply == 'N' ||
charReply == 'y' || charReply == 'n') {
if (charReply == 'Y' || charReply == 'y') {
return 1;
} else {
cout << "/n========================"
<< "/n=Next Flight will be in 3 hours. ="
<< "/n=========================";
return 0;}}}};
cout << "/n================================"
<< "/n= Invalid Input!! Please try again! ="
<< "/n===========================";
return 0;}
int clFlight::assignSeat()
{if (charSection == '1') {
firstclasscnt = firstclasscnt + 1;
return firstclasscnt; };
if (charSection == '2') {
economycnt = economycnt + 1;
return economycnt; }
else return -1;}
//==========================================================
class clDisplay
{private:
public:
void displayMenu();
void displayErrMsg();
void displaySection(char pass_section);
void displaySeat(int pass_seat);};
void clDisplay::displayMenu()
{
cout << "/n======================================="
<< "/n Rosalyn Airline Reservation System "
<< "/n=======================================";
}
void clDisplay::displaySection(char pass_section)
{
cout << "Your section is: " << pass_section << endl;
}
void clDisplay::displaySeat (int pass_seat)
{
cout << "Your seat is: " << pass_seat << endl;
}
//==========================================================
class clBoardingPass
{ private:
public:
void PrintBoardPass (int Section, int intSeat);
};
void clBoardingPass :: PrintBoardPass(int Section, int intSeat)
{
cout << endl;
if (Section == 1){
cout << "/n--------------------------------------"
<< "/n- Boarding Pass for Rosalyn Airline. -"
<< "/n- Section: First Class -"
<< "/n- Seat: " << intSeat << " -"
<< "/n-------------------------------------";
}
else{
cout << "/n------------------------------"
<< "/n- Boarding Pass for Rosalyn Airline. -"
<< "/n- Section: Economy -"
<< "/n- Seat: " << intSeat << " -"
<< "/n-----------------------------";
} }
//=======================================================
int main()
{
char charSeatFull;
char charFirstClassFull;
char charEconomyFull;
int flightchk;
int selectedSection;
int assignSeat;
clFlight obj1;
clDisplay obj2;
clBoardingPass obj3;
obj2.displayMenu();
while(charSeatFull != 'Y'){
flightchk = obj1.chkSection();
if (flightchk == 1 || flightchk == 2){
selectSection = flightchk;
assignSeat = obj1.assignSeat();
obj3.PrintBoardPass(selectSection, assignSeat);}
if (selectedSection == 1 && assignSeat == 5){
charFirstClassFull = 'Y'; };
if (selectSection = 2 && assignSeat == 10){
charEconomyFull = 'Y'; }
if (charFirstClassFull == 'Y' && charEconomyFull == 'Y') {
charSeatFull = 'Y'; } }
return 0;
}
I am getting an error message of "Possible use of 'charSeatFull' before definition in function main(). I looked at the particular char and I don't refer it before the call only when I declare it. I don't understand of why could there be a possible use of before the function main.
Your help is appreciated.
#include <iostream.h>
#include <iomanip.h>
#include <cstring.h>
//=========================================================
class clFlight
{private:
int firstclasscnt;
int economycnt;
char charSection;
public:
clFlight();
int chkSection();
int assignSeat();
};
clFlight::clFlight()
{firstclasscnt = 0;
economycnt = 5;}
int clFlight::chkSection()
{char charReply;
cout << "/nPlease select 1 First Class or 2 Economy: ";
cin >> charSection;
if (charSection == '1'){
if (firstclasscnt < 5){
return 1;
} else {
cout << "/nFirst Class Section is Full. "
<< "/nWould you like the Economy Section instead?"
<< "/nPlease select Y or N: ";
cin >> charReply;
if (charReply == 'Y' || charReply == 'N' ||
charReply == 'y' || charReply == 'n') {
if (charReply == 'Y' || charReply == 'y') {
return 2;
} else {
cout << "/n================================"
<< "/n=The next flight will be in 3 hours.="
<< "/n============================";
return 0; }}}};
if (charSection == '2') {
if (economycnt < 10) {
return 2;
} else {
cout << "/nEconomy Section is Full. "
<< "/nWould you like the First Class Section instead?"
<< "/nPlease Select Y or N: ";
cin >> charReply;
if (charReply == 'Y' || charReply == 'N' ||
charReply == 'y' || charReply == 'n') {
if (charReply == 'Y' || charReply == 'y') {
return 1;
} else {
cout << "/n========================"
<< "/n=Next Flight will be in 3 hours. ="
<< "/n=========================";
return 0;}}}};
cout << "/n================================"
<< "/n= Invalid Input!! Please try again! ="
<< "/n===========================";
return 0;}
int clFlight::assignSeat()
{if (charSection == '1') {
firstclasscnt = firstclasscnt + 1;
return firstclasscnt; };
if (charSection == '2') {
economycnt = economycnt + 1;
return economycnt; }
else return -1;}
//==========================================================
class clDisplay
{private:
public:
void displayMenu();
void displayErrMsg();
void displaySection(char pass_section);
void displaySeat(int pass_seat);};
void clDisplay::displayMenu()
{
cout << "/n======================================="
<< "/n Rosalyn Airline Reservation System "
<< "/n=======================================";
}
void clDisplay::displaySection(char pass_section)
{
cout << "Your section is: " << pass_section << endl;
}
void clDisplay::displaySeat (int pass_seat)
{
cout << "Your seat is: " << pass_seat << endl;
}
//==========================================================
class clBoardingPass
{ private:
public:
void PrintBoardPass (int Section, int intSeat);
};
void clBoardingPass :: PrintBoardPass(int Section, int intSeat)
{
cout << endl;
if (Section == 1){
cout << "/n--------------------------------------"
<< "/n- Boarding Pass for Rosalyn Airline. -"
<< "/n- Section: First Class -"
<< "/n- Seat: " << intSeat << " -"
<< "/n-------------------------------------";
}
else{
cout << "/n------------------------------"
<< "/n- Boarding Pass for Rosalyn Airline. -"
<< "/n- Section: Economy -"
<< "/n- Seat: " << intSeat << " -"
<< "/n-----------------------------";
} }
//=======================================================
int main()
{
char charSeatFull;
char charFirstClassFull;
char charEconomyFull;
int flightchk;
int selectedSection;
int assignSeat;
clFlight obj1;
clDisplay obj2;
clBoardingPass obj3;
obj2.displayMenu();
while(charSeatFull != 'Y'){
flightchk = obj1.chkSection();
if (flightchk == 1 || flightchk == 2){
selectSection = flightchk;
assignSeat = obj1.assignSeat();
obj3.PrintBoardPass(selectSection, assignSeat);}
if (selectedSection == 1 && assignSeat == 5){
charFirstClassFull = 'Y'; };
if (selectSection = 2 && assignSeat == 10){
charEconomyFull = 'Y'; }
if (charFirstClassFull == 'Y' && charEconomyFull == 'Y') {
charSeatFull = 'Y'; } }
return 0;
}