(OT) Method vs member function (was: Re: interfaces :-()

Kirk McDonald kirklin.mcdonald at gmail.com
Tue Jun 20 17:06:33 PDT 2006


Sean Fritz wrote:
> Does B also have a method/function (which do I use with D?) compareTo(A o)?
> 

"A virtual member function is sometimes called a /method/." -Bjarne 
Stroustrup, The C++ Programming Language 3rd ed, section 12.2.6

In D, whether or not a member function is virtual is typically up to the 
compiler. In a sense, the distinction does not matter in D, unless you 
start declaring member functions as "final," which is basically saying 
"this is not virtual." This behavior is functionally similar to Java, in 
which all member functions are virtual; thus the term "method" is 
preferred in that language.

"Member function" will always work, and "method" is usually fine in D. 
You'll usually catch me using "member function" by default, as I come 
from a C++ background.

-Kirk McDonald



More information about the Digitalmars-d-dtl mailing list