Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C++
separating class declaration (header file) and implementation (sourcefile)
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Giovanni Gherdovich, post: 3615240"] Hello, thank you for your answers. mlimber You are completely right. In the code I provided defining "addition" as a function object instead of an ordinary function is just stupid. But I wrote that code to isolate an error wich I had on such a function object... I usually write function objects without state when I have to pass them to algorithms, like the ones in <algorithm> or <numeric>. Since, in this kind of usage, I don't need to istantiate them and I think to them as "functions", sometimes I forgot that they are "classes", like above. And after discovering std::ptr_fun [URL]http://www.cplusplus.com/reference/misc/functional/ptr_fun.html[/URL] I don't need to write such "fake classes" any more... Thank you for the reference to the docs, but mine was only a toy example to reproduce an error I had in the code I'm writing. The addition was not my first concern. Rolf Magnus This _is_ interesting. What semantics has the line you wrote? I admit I was foo when posting my original question, and the first answer made me realize that a class _must_ be instatiated to do something useful. But you seem to use the function object as-it-is.. Can you say more about this, or point to any doc/book/whatever? Thankyou. Regards, Giovanni Gh. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
separating class declaration (header file) and implementation (sourcefile)
Top