program Project7; uses SysUtils; // from here type TCloseIdeLol<T> = record value : T; end; TCloseIdeLolInt = TCloseIdeLol; // to here : no problemo. compiling OK. // from here var Lol : TCloseIdeLolInt; // to here : no problemo. compiling OK. begin // from here Lol.value := 5; // to here : no problemo. compiling OK. end.
program Project7; uses SysUtils; // from here type TCloseIdeLol<TValueA, TValueB> = record // introduce 2 generic types valueA : TValueA; valueB : TValueB; end; TCloseIdeLolInt = TCloseIdeLol; // define to integer and single // to here : no problemo. compiling OK. // from here var Lol : TCloseIdeLolInt; // to here : no problemo. compiling OK. begin // from here Lol.valueA := 5; Lol.valueB := 3.14; // to here : no problemo. compiling OK. end.
program Project7; uses SysUtils; // from here type TCloseIdeLol<TValueA, TValueB> = record // introduce 2 generic types valueA : TValueA; valueB : TValueB; end; TCloseIdeLolInt = TCloseIdeLol; // define to integer and single // now introduce pointer on type here : pCloseIdeLolInt = ^TCloseIdeLolInt; // to here : no problemo. compiling OK. // from here var Lol : TCloseIdeLolInt; // to here : no problemo. compiling OK. begin // from here Lol.valueA := 5; Lol.valueB := 3.14; // to here : no problemo. compiling OK. end.
program Project7; uses SysUtils; // from here type TCloseIdeLol<TValueA, TValueB> = record // introduce 2 generic types valueA : TValueA; valueB : TValueB; end; TCloseIdeLolInt = TCloseIdeLol; // define to integer and single // now introduce pointer on type here : pCloseIdeLolInt = ^TCloseIdeLolInt; // to here : no problemo. compiling OK. // from here var Lol : TCloseIdeLolInt; pLop: pCloseIdeLolInt; // to here : no problemo. compiling OK. begin // from here Lol.valueA := 5; Lol.valueB := 3.14; // to here : no problemo. compiling OK. end.
program Project7; uses SysUtils; // from here type TCloseIdeLol<TValueA, TValueB> = record // introduce 2 generic types valueA : TValueA; valueB : TValueB; end; TCloseIdeLolInt = TCloseIdeLol; // define to integer and single // now introduce pointer on type here : pCloseIdeLolInt = ^TCloseIdeLolInt; // to here : no problemo. compiling OK. // from here var Lol : TCloseIdeLolInt; pLop: pCloseIdeLolInt; // to here : no problemo. compiling OK. begin // from here Lol.valueA := 5; Lol.valueB := 3.14; new(pLop); try pLop^ := Lol; pLop^.valueB := pLop^.valueA * pLop^.valueA; finally dispose(pLop); end; // to here : no problemo. compiling OK. end.
program Project7; uses SysUtils; type TCloseIdeLol<TValueA, TValueB> = record // introduce 2 generic types valueA : TValueA; valueB : TValueB; end; // move up pointer and change TValueB(single) for pCloseIdeLolInt !!! *glups* pCloseIdeLolInt = ^TCloseIdeLolInt; TCloseIdeLolInt = TCloseIdeLol; // ok for the moment, all is good... var Lol : TCloseIdeLolInt; pLop: pCloseIdeLolInt; begin // can use Lol ou pLop without bug ? Lol. RHAAAAAAAAA!
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionprogram Project7; uses SysUtils; type TCloseIdeLol<TValueA, TValueB> = record valueA : TValueA; valueB : TValueB; end; TCloseIdeLolInt = TCloseIdeLol; pCloseIdeLolInt = ^TCloseIdeLolInt; var Lol : TCloseIdeLolInt; pLop: pCloseIdeLolInt; begin Lol.valueA := 5; Lol.valueB := nil; new(pLop); try pLop^ := Lol; pLop^.valueB := pointer(pLop); finally dispose(pLop); end; end.