Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2002-03

Class definition overrides definition in implementation

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Ralf Paaschen

Hi,

the following example program demonstrates the situation. Have a look at the comment at the beginning of the code:

--- SNIP --- HERE FOLLOWS THE CODE ------------ SNIP -------

{
This is a small example program.
The Function "getComment" is declared in the following way: in the class : function getComment : AnsiString; in the implementation : function Parser.getComment : char;

Nevertheless the program seems to compile and work correctly.

Compiler was : Free Pascal Compiler version 1.0.4 [2000/12/18] for i386
Operating System: Linux
Compileroptions : -Sd

Note: The Borland Delphi compiler complains about this situation. }

program test;
type
   Parser=class(TObject)
   public
      function getComment : AnsiString;
      //function getComment : char;
      function setComment(_text:AnsiString);
   private
      Comment: AnsiString;
   end;
   function Parser.setComment(_text:AnsiString);
   begin
      Comment := _text;
   end;
   function Parser.getComment : char;
   begin
      getComment := Comment;
   end;

{----- main program---------------------------------}

Var p:Parser;
var SourceBuffer : AnsiString;
begin
   sourceBuffer := 'Just some text.';
   WriteLn('The source buffer is:',sourceBuffer);
   p:=Parser.create;
   p.setComment(sourceBuffer);
   WriteLn(p.getComment);
   p.free;
end.
Peter Vreman
to Ralf Paaschen
you wrote 9 lines
Hi, the following example program demonstrates the situation. Have a look at the comment at the beginning of the code: { This is a small example program. The Function "getComment" is declared in the following way: in the class : function getComment : AnsiString; in the implementation : function Parser.getComment : char;

Thanks for reporting, I'll add it to the test suite.

Peter