method & function

M

Michael

Hi,

What's the difference between method & funciton in class concept in
C++?

Thanks in advance,
Michael
 
T

Thomas J. Gritzan

Michael said:
Hi,

What's the difference between method & funciton in class concept in
C++?

There are no methods in C++. There are only functions. What do you mean?
 
D

Daniel Smith

Co-ask, and what is the difference between 'variable' and 'attribute'?
I just saw these two in one article (global variable, static
attribute). Thanks.
 
V

Victor Bazarov

Michael said:
What's the difference between method & funciton in class concept in
C++?

There is a *method* to this madness...

Generally, a class contains member *functions* along with data members.
Data members represent objects in memory, member *functions* provide
the object's (class') behaviour.

V
 
V

Victor Bazarov

Daniel said:
Co-ask, and what is the difference between 'variable' and 'attribute'?
I just saw these two in one article (global variable, static
attribute). Thanks.

Please do not top-post.

'Variable' is not a C++ term. It's a generic programming term and it
designates an object that can change its value during the execution
of the program. For example, a reference is not really a variable,
since it cannot change what it refers to, once initialised.

"Attribute"? I am not sure I've heard it in any C++ context. It could
be a synonym for "trait", and there are "type traits" in C++...

V
 
D

Daniel T.

"Michael said:
Hi,

What's the difference between method & funciton in class concept in
C++?

"Method" is not used in C++. We use the term "member-function".
 
M

Mark P

Michael said:
Hi,

What's the difference between method & funciton in class concept in
C++?

Thanks in advance,
Michael

None in my opinion, but some people reserve the term "method" to refer
specifically to virtual functions (but this is OO lingo, not C++
terminology).
 
P

Phlip

Michael said:
What's the difference between method & funciton in class concept in
C++?

All named blocks of code - named with a linkable entry point like foo() -
are either functions, constructors, or destructors. (The Standard sez
constructors and destructors are not functions. They are blocks of code that
bind to object lifespans.)

A function inside a class is a member function.

When using OO design, we send "messages" to objects, and they respond with
"methods". These words are jargon and have no fixed meaning. Roughly, the
message is often the name of a member function, as invoked, such as
anObject.foo(). Then the method is the contents of Object::foo().

And sometimes we say "method" to mean a virtual member function. Yet again
nothing defines these words but their contexts.
 
O

osmium

Michael said:
What's the difference between method & funciton in class concept in
C++?

Method is Smalltalk speak for what C++ calls a member function. I prefer
the Smalltalk terminology, why use a two word phrase when there is a
perfectly adequate *word*?.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top