Anonymous user
Classes: Difference between revisions
→{{header|Pop11}}
m (→{{header|Phix}}: updated to 1.0.2, with constructor and destructor, syntax colouring.) |
|||
Line 3,228:
;;; Print it
instance1 =></lang>
=={{header|Portugol}}==
{{trans|D}}
<lang Portugol>
programa {
inclua biblioteca Objetos --> obj
// "constructor" returns address of object
funcao inteiro my_class_new(inteiro value) {
inteiro this = obj.criar_objeto()
obj.atribuir_propriedade(this, "variable", value) // add property to object
retorne this
}
// "method" takes the address returned by criar_objeto
funcao my_class_some_method(inteiro this) {
my_class_set_variable(this, 1)
}
// "setter"
funcao my_class_set_variable(inteiro this, inteiro value) {
obj.atribuir_propriedade(this, "variable", value)
}
// "getter"
funcao inteiro my_class_get_variable(inteiro this) {
retorne obj.obter_propriedade_tipo_inteiro(this, "variable")
}
funcao inicio() {
inteiro this = my_class_new(0)
escreva("variable = ", my_class_get_variable(this), "\n")
my_class_some_method(this)
escreva("variable = ", my_class_get_variable(this), "\n")
my_class_set_variable(this, 99)
escreva("variable = ", my_class_get_variable(this), "\n")
obj.liberar_objeto(this)
}
}
</lang>
=={{header|PowerShell}}==
|