[fpc-pascal] Interesting namespace question

ik idokan at gmail.com
Thu Jun 21 18:52:45 CEST 2007


Hi,

Thank you all for the answer. I learned that i can do program_name.
for namespace as well cool :)

Ido

On 6/21/07, Tom York <tyork at yorkinfo.com> wrote:
> 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 at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>


-- 
http://ik.homelinux.org/



More information about the fpc-pascal mailing list