oop field



oop field
Smart pascal source code
type TMyClass = class Field: Float; constructor Create(var value: Float); end; constructor TMyClass.Create(var value: Float); begin Field := value; value := value / 2; end; var f: Float = 1 + 0.5; var o: TMyClass = TMyClass.Create(f); var o2: TMyClass; o2 := o; WriteLn(FloatToStr(o.Field)); o2 := TMyClass.Create(f); WriteLn(FloatToStr(o2.Field)); WriteLn(FloatToStr(o.Field)); {<<< RESULT - CONSOLE LOG >>> ----------------------------- 1.5 0.75 1.5 ----------------------------- {<<<<<<<<< THE END >>>>>>>>>}