Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > question about ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 5 Topic 43361 of 48020
Post > Topic >>

question about local class in a function

by Nan Li <nan.li.g@[EMAIL PROTECTED] > Feb 16, 2008 at 11:55 PM

Hello,
    Can any one explain why the following code cannot get compiled ??
Thanks.

#include <iostream>
#include <string>
#include <vector>
#include <iterator>
#include <algorithm>

using namespace std;

int main(int argc, char* argv[])
{
  struct A
  {
    void operator()(int i)
    {
       cout << i <<  endl;
    }
  };

  vector<int> v(3);

  for_each( v.begin(), v.end(), A() );

  return 0;
}

c.cpp: In function 'int main(int, char**)':
c.cpp:21: error: no matching function for call to
'for_each(__gnu_cxx::__normal_iterator<int*, std::vector<int,
std::allocator<int> > >, __gnu_cxx::__normal_iterator<int*,
std::vector<int, std::allocator<int> > >, main(int, char**)::A)'
 




 5 Posts in Topic:
question about local class in a function
Nan Li <nan.li.g@[EMAI  2008-02-16 23:55:01 
Re: question about local class in a function
Ian Collins <ian-news@  2008-02-17 21:58:15 
Re: question about local class in a function
Salt_Peter <pj_hern@[E  2008-02-17 01:30:16 
Re: question about local class in a function
Jerry Coffin <jcoffin@  2008-02-17 05:38:02 
Re: question about local class in a function
"Jim Langston"   2008-02-17 18:02:53 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Oct 14 8:51:25 CDT 2008.