12.07.2015 Views

ILOG OPL Development Studio Language Reference Manual

ILOG OPL Development Studio Language Reference Manual

ILOG OPL Development Studio Language Reference Manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

User-defined constructorsIn addition to the Object constructor, any user-defined function can be used as an objectconstructor.User-defined constructorsSyntaxnew function(arg1, ..., argn)EffectCreates a new object, then calls function(arg1, ..., argn) toinitialize it.Inside the constructor, the keyword this can be used to make reference to the object beinginitialized.For example, the following program defines a constructor for cars:function Car(name, year) {this.name = name;this.year = year;this.start = start_engine;}Now, callingnew Car("Ford", "1985")creates a new object with the properties name and year, and a start method.248I L O G O P L D E V E L O P M E N T S T U D I O L A N G U A G ER E F E R E N C E M A N U A L

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!