Hi!  New list member here...

> I saw an interesting bug on C++, and I was wondering how to solve this
> type of bug in Pascal:

This is easily resolved.

Try this version:
{$MODE OBJFPC}
program namespace_test;

function test : boolean;
begin
writeln('public function test called.');
result := true;
end;

type
TTest = class
   function test : boolean;
end;

function TTest.test : boolean;
begin
writeln('method TTest.test called.');
result := test;
end;

var
c_test : TTest;

begin
c_test := TTest.create;
try
  writeln (c_test.test); // calls the class method
  writeln (namespace_test.test); // calls the public function
finally
  c_test.free;
end;
end.


Tom
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to