Overloading Class Methods

General FreeBASIC programming questions.
Eclipzer
Posts: 432
Joined: Oct 01, 2005 10:50
Location: Maryland
Contact:

Overloading Class Methods

Postby Eclipzer » Nov 15, 2008 7:05

So, I stumbled upon the fact that FB doesn't require class methods to be explicitly overloaded:

Code: Select all

  type myClass
    as integer dummy
    declare sub method(value as integer)
    declare sub method(text  as string)
  end type
 
  sub myClass.method(value as integer)
    ? value
  end sub
 
  sub myClass.method(text as string)
    ? text
  end sub
 
 
  dim as myClass object
 
  object.method(1)
  object.method("abc")
 
  sleep


Just curious to know if this is a bug, or why this is the case and whether or not I should explictly overload my class methods anyway.
v1ctor
Site Admin
Posts: 3799
Joined: May 27, 2005 8:08
Location: SP / Bra[s]il
Contact:

Postby v1ctor » Nov 15, 2008 14:44

Yeah, inside namespaces or classes it's automatic, no 'overload' needed.

That could be used in all cases in -lang fb, but before we had no -lang option and the compatibility with QB was more important (ages ago).

Return to “General”

Who is online

Users browsing this forum: No registered users and 2 guests