Page 1 of 1

Simulating C++ Constructors

Posted: Sat Feb 23, 2013 9:41 pm
by tolkien
Hello friends!

I´m using Hollywood in a OOP way and I ised to use a function like constructor for my objects....you know.
But, what if I want to create a different constructor that accept, for example, arguments? Hoy can I use the same name of the function?

Hope you understand!

Thanks!

Re: Simulating C++ Constructors

Posted: Sun Feb 24, 2013 9:30 am
by Mazze
You could use a function with "variable number of arguments" (see documentation)

Code: Select all

Function test(...)
    ; arguments will be stored in table 'arg'
    DebugPrint(arg.n .. " arguments")
EndFunction

test()
test(5,6)
test(1,9,"aaa",b)

Re: Simulating C++ Constructors

Posted: Sun Feb 24, 2013 4:29 pm
by tolkien
Mazze, you are amazing! ;) Now I remember had read something in the documentation. Thanks!