operator_overloading1 |
Smart pascal source code
function StrPlusInt(s: String; i: Integer): String; begin Result := s + '[' + IntToStr(i) + ']'; end; operator + (String, Integer): String uses StrPlusInt; WriteLn('abc' + 123); var s := 'abc' + 123 + 456; WriteLn(Length(s)); WriteLn(s); {<<< RESULT - CONSOLE LOG >>> ----------------------------- abc[123] 13 abc[123][456] ----------------------------- {<<<<<<<<< THE END >>>>>>>>>}