I have a method search that I want to feed an input stream and then put output on an output stream.
void search(std::istream & is, std::ostream & os);
For now I’d like to do this with cin/cout. From the command prompt:
a.out < input_file.txt
In main, I try to do this by passing cin/cout to the search() method.
X.search(std::cin, std::cout);
I get the following error when I compile and link (XCode):
Line Location Tool:0: collect2: ld returned 1 exit status
Line Location Tool:0: symbol(s) not found
Line Location Tool:0: _main in main.o
Line Location Tool:0: "X::search(std::basic_istream<char, std::char_traits<char> >&,
std::basic_ostream<char, std::char_traits<char> >&)", referenced from:
Is there anything different I need to be doing for cin/cout? I cannot figure out how to resolve this error.
This compiles and runs fine for me in xcode (c++ cmdline new project wizard), looks like you’re missing an #include <iostream> or main, or a definition of your X class.