Call an object method: Difference between revisions

From Rosetta Code
Content added Content deleted
(→‎Tcl: Added implementation)
m (→‎{{header|Tcl}}: clearer highlighting if we don't use a standard command name; no logical difference)
Line 22: Line 22:
<lang tcl>package require Tcl 8.6
<lang tcl>package require Tcl 8.6
# "Static" (on class object)
# "Static" (on class object)
MyClass method someParameter
MyClass mthd someParameter


# Instance
# Instance
$myInstance method someParameter</lang>
$myInstance mthd someParameter</lang>


<!-- Same omits as Class page -->
<!-- Same omits as Class page -->

Revision as of 19:59, 16 August 2011

Task
Call an object method
You are encouraged to solve this task according to the task description, using any language you may know.

In object-oriented programming method is a function associated with a particular class. Methods can be static, associated with the class itself, or instance, associated with an instance of class.

ActionScript

<lang actionscript>// Static MyClass.method(someParamater);

// Instance myInstance.method(someParamater);</lang>

C++

<lang cpp>// Static MyClass::method(someParamater);

// Instance myInstance.method(someParamater);</lang>

Tcl

<lang tcl>package require Tcl 8.6

  1. "Static" (on class object)

MyClass mthd someParameter

  1. Instance

$myInstance mthd someParameter</lang>