{{fbdoc item="title" value="OVERLOAD"}}----
Specifies that a procedure name can be overloaded

{{fbdoc item="syntax"}}##
	[[KeyPgDeclare|Declare]] [[[KeyPgStatic|Static]]] [[KeyPgSub|Sub]] //procedure_name// [[[KeyPgCdecl|Cdecl]]|[[KeyPgStdcall|Stdcall]]|[[KeyPgPascal|Pascal]]] **Overload** [[[KeyPgAlias|Alias]] //"""external_name"""//] [([//parameter_list//])] [[[KeyPgModuleConstructor|Constructor]] [//priority//]] [[[KeyPgStatic|Static]]] [[[KeyPgExport|Export]]]
	
	[[KeyPgDeclare|Declare]] [[[KeyPgStatic|Static]]] [[KeyPgFunction|Function]] //procedure_name// [[[KeyPgCdecl|Cdecl]]|[[KeyPgStdcall|Stdcall]]|[[KeyPgPascal|Pascal]]] **Overload** [[[KeyPgAlias|Alias]] //"""external_name"""//] [([//parameter_list//])] [ [[KeyPgByrefFunction|byref]] ] [[KeyPgAs|as]] //return_type// [[[KeyPgStatic|Static]]] [[[KeyPgExport|Export]]]
	
	[[[KeyPgPublic|Public]]|[[KeyPgPrivate|Private]]] [[KeyPgSub|Sub]] //procedure_name// [[[KeyPgCdecl|Cdecl]]|[[KeyPgStdcall|Stdcall]]|[[KeyPgPascal|Pascal]]] **Overload** [[[KeyPgAlias|Alias]] //"""external_name"""//] [([//parameter_list//])] [[[KeyPgModuleConstructor|Constructor]] [//priority//]] [[[KeyPgStatic|Static]]] [[[KeyPgExport|Export]]]
		//..procedure body..//
	[[KeyPgEnd|End]] [[KeyPgSub|Sub]]
	
	[[[KeyPgPublic|Public]]|[[KeyPgPrivate|Private]]] [[KeyPgFunction|Function]] //procedure_name// [[[KeyPgCdecl|Cdecl]]|[[KeyPgStdcall|Stdcall]]|[[KeyPgPascal|Pascal]]] **Overload** [[[KeyPgAlias|Alias]] //"""external_name"""//] [([//parameter_list//])] [ [[KeyPgByrefFunction|byref]] ] [[KeyPgAs|as]] //return_type//  [[[KeyPgStatic|Static]]] [[[KeyPgExport|Export]]]
		//..procedure body..//
	[[KeyPgEnd|End]] [[KeyPgFunction|Function]]
##
{{fbdoc item="desc"}}
	In procedure declarations, ##**Overload**## allows procedure names to be overloaded, that is, other procedures (regardless of whether to be subs or functions) can then be declared with the same name if their parameter lists are unique. Two parameter lists are unique if they contain a different number of parameters, or have parameters of different types. Note that this means that two or more procedures cannot be declared with the same name if they differ in return type alone.
	A variadic procedure name can never be overloaded.
	
	Once a procedure name has been declared overloaded, further declarations using the name need not specify ##**Overload**##, but it is allowed.
	
	##**Overload**## is not necessary in member procedure declarations, as they are always implicitly overloaded.
	
	When calling an overloaded procedure name, a match score is calculated comparing the call argument types with the parameter types for each candidate procedure (major resolution on datatypes themselves, minor resolution on datatype sizes).
	The highest matching score wins. If this highest score is too low, or if several overloaded procedures have the same highest score, the compiler then generates an error at compile time (no matching procedure, or ambiguous call).

{{fbdoc item="ex"}}
{{fbdoc item="filename" value="examples/manual/procs/overload.bas"}}%%(freebasic)
DECLARE FUNCTION SUM OVERLOAD (A AS INTEGER,B AS INTEGER) AS INTEGER
DECLARE FUNCTION SUM OVERLOAD (A AS SINGLE,B AS SINGLE) AS SINGLE
FUNCTION SUM  (A AS INTEGER,B AS INTEGER) AS INTEGER
   FUNCTION=A+B
END FUNCTION   
FUNCTION SUM  (A AS SINGLE,B AS SINGLE) AS SINGLE
   FUNCTION=A+B
END FUNCTION   
DIM AS INTEGER A,B
DIM AS SINGLE A1,B1
A=2
B=3
A1=2.
b1=3.
PRINT SUM(A,B)
PRINT SUM (A1,B1)
SLEEP
%%

{{fbdoc item="diff"}}
	- New to ""FreeBASIC""

{{fbdoc item="see"}}
	- ##[[KeyPgDeclare|Declare]]##
	- ##[[KeyPgSub|Sub]]##, ##[[KeyPgFunction|Function]]##

{{fbdoc item="back" value="CatPgProcedures|Procedures"}}