tb0120.pp 887 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. { %FAIL }
  2. {
  3. This is a small example program.
  4. The Function "getComment" is declared in the following way:
  5. in the class : function getComment : AnsiString;
  6. in the implementation : function Parser.getComment : char;
  7. }
  8. {$mode delphi}
  9. type
  10. Parser=class(TObject)
  11. public
  12. function getComment : AnsiString;
  13. function setComment(_text:AnsiString);
  14. private
  15. Comment: AnsiString;
  16. end;
  17. function Parser.setComment(_text:AnsiString);
  18. begin
  19. Comment := _text;
  20. end;
  21. function Parser.getComment : char;
  22. begin
  23. getComment := Comment;
  24. end;
  25. {----- main program---------------------------------}
  26. Var p:Parser;
  27. var SourceBuffer : AnsiString;
  28. begin
  29. sourceBuffer := 'Just some text.';
  30. WriteLn('The source buffer is:',sourceBuffer);
  31. p:=Parser.create;
  32. p.setComment(sourceBuffer);
  33. WriteLn(p.getComment);
  34. p.free;
  35. end.