An object is polymorphic when its specific type may vary.
The types a specific value may take, is called class.

It is trivial to copy an object if its type is known:

int x;
int y = x;
Here x is not polymorphic, so y is declared of same type (int) as x.
But if the specific type of x were unknown, then y could not be declared of any specific type.

The task: let a polymorphic object contain an instance of some specific type S derived from a type T.
The type T is known.
The type S is possibly unknown until run time.
The objective is to create an exact copy of such polymorphic object (not to create a reference, nor a pointer to).
Let further the type T have a method overridden by S.
This method is to be called on the copy to demonstrate that the specific type of the copy is indeed S.

BEGIN
    # Algol 68 doesn't have classes and inheritence as such, however structures #
    # can contain procedures and different instances of a structure can have    #
    # different versons of the procedure                                        #
    # this allows us to simulate inheritence by creating structure instances    #
    # with different procedures                                                 #
 
    # the following declares a type (MODE) HORSE with two constructors, one for #
    # a standard horse and one for a zebra (the "derived class").               # 
    # The standard horse has its print procedure set to thw print horse         #
    # procedure (the "base class" method). zebras get the print zebra procedure #
    # (the "derived class" method). A convenience operator (PRINT) is defined   #
    # to simplify calling the horse/zebra print method of its horse parameter   #
    # = this PRINT operator is independent of which actual print method the     #
    # horse has - it just saved typeing "( print OF h )( h )" everywhere we     #
    # need to call the print method (euivalent to h.print(h) in e.g. C, Java,   #
    # etc.)                                                                     #
 
    # "class" #
    MODE HORSE = STRUCT( STRING name, PROC(HORSE)VOID print );
    # constructors #
    PROC new horse   = ( STRING name )HORSE: ( name, print horse );
    PROC new zebra   = ( STRING name )HORSE: ( name, print zebra );
    # print methods: one for a standard horse and one for a zebra #
    PROC print horse = ( HORSE  h    )VOID: print( ( "horse: ", name OF h ) );
    PROC print zebra = ( HORSE  h    )VOID: print( ( "zebra: ", name OF h ) );
    # print operator #
    OP   PRINT       = ( HORSE  h    )VOID: ( print OF h )( h );
 
    # declare and construct some horses and zebras #
    HORSE h1 := new horse( "silver blaze" );
    HORSE z1 := new zebra( "stripy" );
    HORSE z2 := new zebra( "second zebra" );
 
    # show their values #
    PRINT h1; print( ( newline ) );
    PRINT z1; print( ( newline ) );
    PRINT z2; print( ( newline ) );
    print( ( "----", newline ) );
 
    # change the second zebra to be a copy of the first zebra #
    z2 := z1;
    PRINT z1; print( ( newline ) );
    PRINT z2; print( ( newline ) );
    print( ( "----", newline ) );
 
    # change the name of the first zebra leaving z2 unchanged #
    name OF z1 := "ed";
    PRINT z1; print( ( newline ) );
    PRINT z2; print( ( newline ) )
END