J
jmoy.matecon
I get an error while compiling the following program:
int main()
{
vector<int> v(istream_iterator<int>(cin),
istream_iterator<int>());
copy(v.begin(),v.end(),ostream_iterator<int>(cout,"\n"));
}
The errors I get are [from gcc v. 4.0.3, amd64, ubuntu linux] is:
readint.cc: In function 'int main()':
readint.cc:12: error: request for member 'begin' in 'v', which
is of non-class type 'std::vector<int, std::allocator<int> >
()(std::istream_iterator<int, char, std::char_traits<char>, long int>,
std::istream_iterator<int, char, std::char_traits<char>, long int>
(*)())'
readint.cc:12: error: request for member 'end' in 'v', which is
of non-class type 'std::vector<int, std::allocator<int> >
()(std::istream_iterator<int, char, std::char_traits<char>, long int>,
std::istream_iterator<int, char, std::char_traits<char>, long int>
(*)())'
I understand this to mean that v is getting defined as a function. Is
this as it should be, or is this a problem with my compiler? Using a
temporary variable for the istream_iterator makes the problem go away.
Jyotirmoy Bhattacharya
int main()
{
vector<int> v(istream_iterator<int>(cin),
istream_iterator<int>());
copy(v.begin(),v.end(),ostream_iterator<int>(cout,"\n"));
}
The errors I get are [from gcc v. 4.0.3, amd64, ubuntu linux] is:
readint.cc: In function 'int main()':
readint.cc:12: error: request for member 'begin' in 'v', which
is of non-class type 'std::vector<int, std::allocator<int> >
()(std::istream_iterator<int, char, std::char_traits<char>, long int>,
std::istream_iterator<int, char, std::char_traits<char>, long int>
(*)())'
readint.cc:12: error: request for member 'end' in 'v', which is
of non-class type 'std::vector<int, std::allocator<int> >
()(std::istream_iterator<int, char, std::char_traits<char>, long int>,
std::istream_iterator<int, char, std::char_traits<char>, long int>
(*)())'
I understand this to mean that v is getting defined as a function. Is
this as it should be, or is this a problem with my compiler? Using a
temporary variable for the istream_iterator makes the problem go away.
Jyotirmoy Bhattacharya