Hi!
ahmadcorp schrieb:
> std::vector<std::string>
> data( std::istreambuf_iterator<std::string>(inputFile) ,
> std::istreambuf_iterator<std::string>())
[snip]
> error: request for member `begin' in `data', which is of non-aggregate
> type `std::vector<std::string, std::allocator<std::string> > ()
> (std::istreambuf_iterator<std::string, std::char_traits<std::string>
>> , std::istreambuf_iterator<std::string, std::char_traits<std::string>
>> (*)())'
The "data" variable is not a variable at all. That is because the
declaration of "data" can be interpreted as a function declaration. The
compiler is required to prefer that. Thus "data" is a function. And
functions don't have "begin()" and "end()".
It can be solved by having extra variables:
void foo(std::istream& file)
{
using namespace std;
istream_iterator<string> first(file), last;
vector<string> data(first, last);
data.begin(); //works
}
HTH, Frank