[fpc-pascal] Interesting namespace question
Tom York
tyork at yorkinfo.com
Thu Jun 21 17:03:28 CEST 2007
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
More information about the fpc-pascal
mailing list