Solved

problems using bind2nd

Posted on 2002-05-03
2
261 Views
Last Modified: 2006-11-17
Hi,
I'm using following line in Visual Studio:
for_each(Array.begin(),Array.end(),
bind2nd(mem_fun(&Vertex::Calculate),Radius));

when Array is a std::vector of pointers to Vertex.
class Vertex
{
public:
...
   void Calculate(double Radius);
...
}

But then I get the following error:
error C2784: 'class std::mem_fun_t<_R,_Ty> __cdecl std::mem_fun(_R (__thiscall _Ty::*)(void))' : could not deduce template argument for '<Unknown>' from 'void (__thiscall Vertex::*)(double)'

what could be the problem? And how to fix it?
thanks
0
Comment
Question by:borlip
  • 2
2 Comments
 
LVL 3

Accepted Solution

by:
GGRUNDY earned 50 total points
ID: 6989235
Initial comment....
as your member function takes and argument you need to be using mem_fun1.

(I know it doesnt' say this in Bjarne's 3rd edition)
0
 
LVL 3

Expert Comment

by:GGRUNDY
ID: 6989262
and...
I had to make the Calculate function return an integer just to keeps the templates happy :-(

class Vertex
{
public:
...
  int Calculate(double Radius);
...
}

see http://cpptips.hyperformix.com/cpptips/ret_void_ref
for more info. Bjarne is onto it :-)

0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now