In C++ are member functions supposed to be called 'member functions' or 'class methods'? Just curious.
In C++ are member functions supposed to be called 'member functions' or 'class methods'? Just curious.
-- Will you show me how to c++?
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
Thank you!
-- Will you show me how to c++?
You can use the term method to refer to a virtual member function.Originally Posted by mramazing
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
"method" is a generic object-oriented term, and "member function" is a distinctly C++ term, but they mean the same thing in this context. However, the term "class method" sounds, at least from a Java perspective, like it refers to static functions (i.e. functions that can be called without this pointer, without an object to operate on).
Code:class Something { public: static void staticFunc() {} }; int main() { // called without an object of type Something to operate on Something::staticFunc(); return 0; }
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
Somewhat: as I mentioned, method can be used as a C++ term to refer specifically to a virtual member function, which is really more akin to a method in a general OOP sense since you cannot override a non-virtual member function.Originally Posted by dwks
Agreed, though I note that "static functions" could refer to free functions that are declared static, but here the use is to refer to static member functions.Originally Posted by dwks
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
I haven't really seen that distinction made before, but it makes sense. So I guess you could define a "member function" as a function which resides inside a class, whether virtual or non-virtual or static.
True -- I was trying to avoid circular definitions here and so presented an example instead.Agreed, though I note that "static functions" could refer to free functions that are declared static, but here the use is to refer to static member functions.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"