D
D. Susman
Hi,
In the code snippet below, I am trying to read the contents of a file
into a vector. However I can't get it compiled. I am using Sunstudio
which compiles C++ using cc.
Here is the code:
#include <fstream>
#include <vector>
int main( int argc, char ** argv )
{
std::ifstream input( "input.txt" );
std::istream_iterator<int> dataBegin( input );
std::istream_iterator<int> dataEnd;
std::vector<int> v( dataBegin, dataEnd ); //Compiler error
return (EXIT_SUCCESS);
}
Compiler error: Could not find a match for
std::vector<int>::vector(std::istream_iterator<int, char,
std::char_traits<char>, int>, std::istream_iterator<int, char,
std::char_traits<char>, int> ) needed in main(int, char**);
In the code snippet below, I am trying to read the contents of a file
into a vector. However I can't get it compiled. I am using Sunstudio
which compiles C++ using cc.
Here is the code:
#include <fstream>
#include <vector>
int main( int argc, char ** argv )
{
std::ifstream input( "input.txt" );
std::istream_iterator<int> dataBegin( input );
std::istream_iterator<int> dataEnd;
std::vector<int> v( dataBegin, dataEnd ); //Compiler error
return (EXIT_SUCCESS);
}
Compiler error: Could not find a match for
std::vector<int>::vector(std::istream_iterator<int, char,
std::char_traits<char>, int>, std::istream_iterator<int, char,
std::char_traits<char>, int> ) needed in main(int, char**);