In C++ are member functions supposed to be called 'member functions' or 'class methods'? Just curious.
This is a discussion on Which is correct? within the C++ Programming forums, part of the General Programming Boards category; 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:int main(void){srand(time(0));for(double l=rand(),l0=0,l00=0;;l0+=0.1){for(double l000=0;l000 <1;l000+=.001,l+=((double)rand()/RAND_MAX)/0x64,l00+=((sin(l*0x8*atan(l0)*l000-(l0*0x8*atan (l)))*0.5)+0.5)){l00-=floor(l00);for(size_t l0000=0,l00000=(size_t)(0x50*(l00));l0000<l00000;++l0000 )putchar(0x20);putchar(0x61+(int)((double)rand()/RAND_MAX*0x1a));putchar('\n');}}return 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
C + C++ Compiler: MinGW port of GCC
Version Control System: Bazaar
Look up a C++ Reference and learn How To Ask Questions The Smart Way
"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
C + C++ Compiler: MinGW port of GCC
Version Control System: Bazaar
Look up a C++ Reference and learn How To Ask Questions The Smart Way
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"