Error LNK2019 and truncation (tips?)

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;
}
}


// 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;
}
}
}
}



Output:
1>------ Build started: Project: Airline Reservation, Configuration: Debug Win32 ------
1> airline reservation.cpp
1>c:\users\wicuser\documents\visual studio 2010\projects\airline reservation\airline reservation\airline reservation.cpp(23): warning C4305: '=' : truncation from 'bool (__cdecl *)(int)' to 'bool'
1>c:\users\wicuser\documents\visual studio 2010\projects\airline reservation\airline reservation\airline reservation.cpp(23): warning C4800: 'bool (__cdecl *)(int)' : forcing value to bool 'true' or 'false' (performance warning)
1>c:\users\wicuser\documents\visual studio 2010\projects\airline reservation\airline reservation\airline reservation.cpp(28): warning C4551: function call missing argument list
1>airline reservation.obj : error LNK2019: unresolved external symbol "bool __cdecl availability_Checking(int)" (?availability_Checking@@YA_NH@Z) referenced in function _main
1>airline reservation.obj : error LNK2019: unresolved external symbol "int __cdecl option_Select(void)" (?option_Select@@YAHXZ) referenced in function _main
1>C:\Users\wicuser\documents\visual studio 2010\Projects\Airline Reservation\Debug\Airline Reservation.exe : fatal error LNK1120: 2 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I copied your code into my IDE and had it indent the code for me. The error is immediately obvious this way.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#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;
        }
    }


    // 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.
Last edited on
Thank you so much. I knew it was something simple I was overlooking!
Topic archived. No new replies allowed.