i use a class static member function to for_each:
class t1
{
static test(string s);
}
main()
{
list<string> slist;
...
for_each(slist.begin(), slist.end(), t1::test);
}
this can run, but when i give t1::test a parameter,like this :
class t1
{
static test2(string s, int 5);
}
main()
{
for_each(slist.begin(), slist.end(), bind2nd(t1::test2,5) ); //error !!!
for_each(slist.begin(), slist.end(), bind2nd(ptr_fun(t1::test2,5) ) );
//also error !!!
}
how to resolve this problem? 2 1500
flyaflya wrote: i use a class static member function to for_each: class t1 { static test(string s); }
main() { list<string> slist; ... for_each(slist.begin(), slist.end(), t1::test); } this can run, but when i give t1::test a parameter,like this : class t1 { static test2(string s, int 5); } main() { for_each(slist.begin(), slist.end(), bind2nd(t1::test2,5) ); //error !!! for_each(slist.begin(), slist.end(), bind2nd(ptr_fun(t1::test2,5) ) ); //also error !!! }
how to resolve this problem?
for_each(slist.begin(), slist.end(), bind2nd(ptr_fun(t1::test2),5 ) );
"flyaflya" <fl******@gmail.com> wrote in
news:d3**********@mail.cn99.com: i use a class static member function to for_each: class t1 { static test(string s); }
main() { list<string> slist; ... for_each(slist.begin(), slist.end(), t1::test); } this can run, but when i give t1::test a parameter,like this : class t1 { static test2(string s, int 5); } main() { for_each(slist.begin(), slist.end(), bind2nd(t1::test2,5) ); //error !!! for_each(slist.begin(), slist.end(), bind2nd(ptr_fun(t1::test2,5) ) ); //also error !!! }
how to resolve this problem?
First, post a short _compilable_ example of your problem. Use copy and
paste, don't attempt to type it in since you may make transcription
errors.
As an example, you don't give the 2nd parameter to test2 a name. And,
Standard C++ doesn't do default return values from functions, so a proper
declaration for main is "int main()" This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: jack |
last post by:
Hi all,
Suppose I have a routine to find the maximum
of any *univariate* function f in the interval :
double f(double x);
double findmax(double (*func)(double), double a, double b);
Now I...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |