473,320 Members | 1,961 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

syntax for mem_fun needed

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
1 1398
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Old Wolf | last post by:
I have a member function that acts on an object. I would also like to have a member function that acts on a container of such objects, using std::for_each. I tried: #include <algorithm>...
2
by: Robbie Hatley | last post by:
I've got a function that I use a lot when making utility programs that need to do the same thing to every directory in a tree. Its prototype is: unsigned long int CursDirs (void Func(void)); ...
9
by: Mr X | last post by:
Can anyone tell how to fix the compile error for the program below? #include "iostream.h" #include <vector> #include <algorithm> #include <functional> #include <list> using namespace std;
13
by: Ioannis Vranos | last post by:
What is the exact difference between mem_fun and mem_fun_ref, since in all examples I looked at, they are used in exactly the same way? -- Ioannis Vranos http://www23.brinkster.com/noicys
4
by: ShaneG | last post by:
We have ptr_fun to handle functions, mem_fun to handle member functions that will be called through a pointer, and mem_fun_ref to handle member functions that will be called through a reference. ...
4
by: joseph cook | last post by:
I am getting a compile error on any compiler I try, so I know I have an error here. Can anyone see it? //includes class Foo { public: Foo(int a){m_hi = a;} int hi(){return m_hi;}
1
by: subramanian100in | last post by:
Consider the following program: #include <iostream> #include <string> #include <list> #include <algorithm> using namespace std; class Test
8
by: flopbucket | last post by:
Hi, I am having some problem using std::bind1st() and mem_fun. I want to bind member function calls to some kind of functor so it can be called later. The following works fine for me: ...
1
by: jonnyothan | last post by:
The following code isn't producing expected results: class Selectable { bool IsSelected() const; }; class Unit : public Selectable { };
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.