Inner classes: Difference between revisions
Content added Content deleted
(Added Algol 68) |
(→{{header|ALGOL 68}}: Hide the print methods in the constructors) |
||
Line 50: | Line 50: | ||
PROC new outer = REF REF OUTER: |
PROC new outer = REF REF OUTER: |
||
BEGIN |
BEGIN |
||
HEAP OUTER thisv := OUTER( 0 |
HEAP OUTER thisv := OUTER( 0 |
||
⚫ | |||
, NIL |
|||
, ( REF OUTER this )VOID: |
|||
⚫ | |||
); |
|||
HEAP REF OUTER this := thisv; |
HEAP REF OUTER this := thisv; |
||
oinner OF this := new inner( this ); |
oinner OF this := new inner( this ); |
||
Line 57: | Line 62: | ||
PROC new inner = ( REF REF OUTER super )REF REF INNER: |
PROC new inner = ( REF REF OUTER super )REF REF INNER: |
||
BEGIN |
BEGIN |
||
HEAP INNER thisv := INNER( super |
HEAP INNER thisv := INNER( super |
||
⚫ | |||
, new inner |
|||
, ( REF INNER this )VOID: |
|||
⚫ | |||
⚫ | |||
, ">>" |
|||
) |
|||
) |
|||
); |
|||
HEAP REF INNER this := thisv; |
HEAP REF INNER this := thisv; |
||
this |
this |
||
END # new inner # ; |
END # new inner # ; |
||
⚫ | |||
PROC print outer = ( REF OUTER this )VOID: |
|||
⚫ | |||
PROC print inner = ( REF INNER this )VOID: |
|||
⚫ | |||
⚫ | |||
⚫ | |||
) |
|||
); |
|||
REF OUTER o := new outer; # create an instance of OUTER # |
REF OUTER o := new outer; # create an instance of OUTER # |