good afternoon,
I am receiving an error message of 'function should return a value in clFlight::assignSeat' although I am passing a value. I looked it over and I can't see what i am doing wrong in the code below. Am I missing something stupid?
#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 hrs.="
<< "/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;
};
}
I am receiving an error message of 'function should return a value in clFlight::assignSeat' although I am passing a value. I looked it over and I can't see what i am doing wrong in the code below. Am I missing something stupid?
#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 hrs.="
<< "/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;
};
}