By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,563 Members | 1,280 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,563 IT Pros & Developers. It's quick & easy.

syntax for mem_fun needed

P: n/a
Suppose I have

class WordAndLineNumbers
{
public:
void print( );

// other member functions
private:
// data members
};

vector<WordAndLineNumbersv;

for_each( v.begin( ), v.end( ), mem_fun(&WordAndLineNumbers::print));

The above usage of mem_fun gives compilation error.

Kindly correct me and give the right syntax for mem_fun.

Thanks
V.Subramanian

Sep 30 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
su**************@yahoo.com, India wrote:
Suppose I have

class WordAndLineNumbers
{
public:
void print( );

// other member functions
private:
// data members
};

vector<WordAndLineNumbersv;

for_each( v.begin( ), v.end( ), mem_fun(&WordAndLineNumbers::print));

The above usage of mem_fun gives compilation error.

Kindly correct me and give the right syntax for mem_fun.
The element type of the vector is WordAndLineNumbers, not pointer type,
"mem_fun" is to work with pointer type,
use "mem_fun_ref" instead
--
Thanks
Barry
Sep 30 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.