So here is the code I’m working with. I would like to be able to pass all of the input into this function new_flight which there is currently no code for other then an empty declaration. I’m trying to pass tokens by reference but I’ve tried it with * & and just by value, and none seem to work.
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <iterator>
using namespace std;
void new_flight( vector<string> &tokens );
int main( int argc, char *argv[] )
{
vector<string> tokens;
cout << "Reservations >> ";
getline(cin, input);
istringstream iss( input );
copy(istream_iterator<string>( iss ),
istream_iterator<string>(),
back_inserter<vector<string> > ( tokens ));
new_flight( tokens );
}
Here is what the compiler is telling me
Undefined symbols for architecture x86_64:
"new_flight(std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&)", referenced from:
_main in ccplPBEo.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
also if I comment out the line where I actually pass tokens to new_flight new_flight( tokens ) it compiles fine.
Thanks for taking a look
In order to stub out a function you need to provide a function definition, not a function declaration: