Can someone tell me where I am going wrong? I have been researching the Error LNK 2019 and I know what that is but I have tried changing the definitions and I cannot get anything to work. I did change a couple definitions just messing around to see what would happen. One error goes away and three more appear. The new errors are with truncation with the bool. Any and all insight is greatly appreciated!
#include <iostream>
using namespace std;
int option_Select();
bool availability_Checking(int);
void reserve_Boarding(int);
int capacity[80] = {0};
int section;
int opt;
int main()
{
int option;
bool availability = false;
for(int x = 0; x < 12; x++)
{
// option select
option = option_Select();
// check seats availability in selected section
availability = availability_Checking;
if(availability == 1)
{
// if there is available place print boarding pass
reserve_Boarding;
}
else
// if there is no available place, check seats availability in other section
{
cout << "Sorry, there are no seats available. Please choose another section";
}
}
// display message and option select
int option_Select();
{
int class_Option;
cout << "Please type 1 for First Class" << endl;
cout << "Please type 2 for Coach" << endl;
cin >> class_Option;
while(class_Option != 1 && class_Option != 2)
{
cout << "Please enter correct option!" << endl;
cout << "Please type 1 for First Class" << endl;
cout << "Please type 2 for Coach" << endl;
cin >> class_Option;
}
return class_Option;
}
// seats availability
bool availability_Checking(int);
{
int counter_a = 0;
int counter_b = 0;
if(opt == 1)
{
for(int i = 0; i < 20; i++)
{
if(capacity[i] == 0)
counter_a++;
}
}
else
{
for(int j = 20; j < 80; j++)
{
if(capacity[j] == 0)
counter_b++;
}
}
if((opt == 1 && counter_a > 0) || (opt == 2 && counter_b > 0))
{
cout << "There is an available place in section " << endl;
return 1;
}
else
{
cout << "There is no available place in section " << endl;
return 0;
}
}
#include <iostream>
usingnamespace std;
int option_Select();
bool availability_Checking(int);
void reserve_Boarding(int);
int capacity[80] = {0};
int section;
int opt;
int main()
{
int option;
bool availability = false;
for(int x = 0; x < 12; x++)
{
// option select
option = option_Select();
// check seats availability in selected section
availability = availability_Checking;
if(availability == 1)
{
// if there is available place print boarding pass
reserve_Boarding;
}
else
// if there is no available place, check seats availability in other section
{
cout << "Sorry, there are no seats available. Please choose another section";
}
}
// display message and option select
int option_Select();
{
int class_Option;
cout << "Please type 1 for First Class" << endl;
cout << "Please type 2 for Coach" << endl;
cin >> class_Option;
while(class_Option != 1 && class_Option != 2)
{
cout << "Please enter correct option!" << endl;
cout << "Please type 1 for First Class" << endl;
cout << "Please type 2 for Coach" << endl;
cin >> class_Option;
}
return class_Option;
}
// seats availability
bool availability_Checking(int);
{
int counter_a = 0;
int counter_b = 0;
if(opt == 1)
{
for(int i = 0; i < 20; i++)
{
if(capacity[i] == 0)
counter_a++;
}
}
else
{
for(int j = 20; j < 80; j++)
{
if(capacity[j] == 0)
counter_b++;
}
}
if((opt == 1 && counter_a > 0) || (opt == 2 && counter_b > 0))
{
cout << "There is an available place in section " << endl;
return 1;
}
else
{
cout << "There is no available place in section " << endl;
return 0;
}
}
// reserve seat and print boarding pass
void reserve_Boarding(int);
{
int seat = 0;
if(section == 1)
{
for(int i = 0; i < 20; i++)
{
if(capacity[i] == 0)
{
capacity[i] = 1;
seat = i + 1;
}
if(seat != 0)
break;
}
if(seat != 0)
{
cout << "Your section: " << section<<endl;
cout << "Your seat: " << seat << endl;
}
}
else
{
for(int j = 20; j < 80; j++)
{
if(capacity[j] == 0)
{
capacity[j] = 1;
seat = j + 1;
}
if(seat != 0)
break;
}
if(seat != 0)
{
cout << "Your section: " << section<<endl;
cout << "Your seat: " << seat << endl;
}
}
}
}
Look at how the braces align. You're trying to define all your functions inside main(). This is not correct.
The reason it got through compilation and failed on link is because on lines 38, 61, and 96 you end the function name with semicolons, so the compiler treats these lines as declarations. The blocks that come inside the curly braces afterward are just unnamed scopes. Technically legal. However, when it comes time for the linker to go bind definitions to these calling points it can't find any definitions. All you have in your code are declarations. Review how functions are typically defined and you should be able to resolve this.