Anonymous user
Call an object method: Difference between revisions
Added COBOL section. Corrected C# section position. Fixed PL/SQL lang tag.
(Added COBOL section. Corrected C# section position. Fixed PL/SQL lang tag.) |
|||
Line 27:
myInstance := new myClass
myInstance.Method("bye")</lang>
=={{header|C_sharp|C#}}==▼
<lang csharp>// Static▼
MyClass.Method(someParameter);▼
// Instance▼
myInstance.Method(someParameter);</lang>▼
=={{header|Bracmat}}==
Line 62 ⟶ 56:
// Instance
myInstance.method(someParameter);</lang>
▲=={{header|C_sharp|C#}}==
▲<lang csharp>// Static
▲MyClass.Method(someParameter);
▲// Instance
▲myInstance.Method(someParameter);</lang>
=={{header|COBOL}}==
COBOL has two ways to invoke a method: the <code>INVOKE</code> statement and inline method invocation.
<lang cobol>*> INVOKE
INVOKE FooClass "someMethod" RETURNING bar *> Factory object
INVOKE foo-instance "anotherMethod" RETURNING bar *> Instance object
*> Inline method invocation
MOVE FooClass::"someMethod" TO bar *> Factory object
MOVE foo-instance::"anotherMethod" TO bar *> Instance object</lang>
To call factory methods of objects of an unknown type (such as when you may have a subclass of the class wanted), it is necessary to get a reference to the class's factory object by calling the <code>"FactoryObject"</code> method.
<lang cobol>INVOKE foo-instance "FactoryObject" RETURNING foo-factory
*> foo-factory can be treated like a normal object reference.
INVOKE foo-factory "someMethod"</lang>
=={{header|CoffeeScript}}==
Line 830 ⟶ 846:
=={{header|PL/SQL}}==
<lang
-- A class needs at least one member even though we don't use it
dummy NUMBER,
|