|
|
![]() |
| Thread Tools | Search this Thread |
#1
| |||
| |||
Passing function parameter and static Code: #include <string> #include <iostream> using namespace std; struct Functor{ bool operator()(const std::string& str){cout<<str<<endl;return true;} }; struct Functor2{ static bool compute(const std::string& str){cout<<str<<endl;return true;} }; struct Foo { template<class F> void callMe() { F()("operator ()"); } template<class F> void callMe2() { F::compute("static"); } }; int main(int n,char ** arfv) { Foo obj; obj.callMe<Functor>(); obj.callMe2<Functor2>(); system("pause"); } |
#2
| |||
| |||
Re: Passing function parameter and static What is static over here? Static method means a state where the compiler does not allow any reentry. That means, you cannot change anything in that method or variable. In short, none of the two is recommended. The idiom favored by the standard: Code: template<class Fun> void callMe( Func f) { f("operator ()" ); } |
#3
| |||
| |||
Re: Passing function parameter and static I recently read a language such as ADA which is assumed to be better than C++ programming for parallel/concurrent. And with the next version of C++ or the development of third-lib, we can not hope that one day the C++ is doing better in this area? Any comments? |
#4
| |||
| |||
Re: Passing function parameter and static Quote:
Regarding ADA: Ada is a structured, statically typed, imperative, wide-spectrum, and object-oriented high-level computer programming language, extended from Pascal and other languages. Ada is strongly typed and compilers are validated for reliability in mission-critical applications, such as avionics software. |
![]() |
|
Tags: function parameter, static keyword |
Thread Tools | Search this Thread |
|
![]() | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Passing object as a parameter in a method | Karumbu | Software Development | 4 | 06-01-2011 01:07 AM |
Passing an ArrayList From the Form as Parameter | Sheenas | Software Development | 8 | 20-06-2010 10:45 AM |
Passing "file" parameter in a function | kamina23 | Software Development | 3 | 29-10-2009 11:07 PM |
Passing parameter of Oracle procedure in PHP | Halina | Software Development | 3 | 22-04-2009 08:46 PM |
Parameter passing using NavigateURL | Sachit | Software Development | 3 | 26-03-2009 09:25 AM |