Overloading
You are here :

Sub nodes

Recent changes
Site plan
 
This page is not available in requested lang, reverting to default lang
 

This is a means to create several methods (or operators or properties) having the same name, but different arguments and/or constness.

That is :

 class SomeClass {
   public sub f() const {
   }
   public sub f() {
   }
 }

is legal (constness is different)

and :

 class SomeClass {
   public sub f() {
   }
   public sub f(const int i) {
   }
 }

is legal (arguments are different)

whereas :

 class SomeClass {
   public sub f() {
   }
   public int f() {
     return 0;
   }
 }

is not legal because it is forbidden to differentiate a method on the result value.

Sometime, overloading can reach another pace when coupled with polymorphism. In this case, we call it multi methods.

Propulsed by Wiclear