Re: [fpc-pascal] Understanding virtual methods

2013-08-20 Thread Martin
On 20/08/2013 02:44, Xiangrong Fang wrote: Hi All, I am reading this document: http://www.freepascal.org/docs-html/ref/refsu29.html and doing an experiment with the following code: program project1; {$mode objfpc}{$H+} type TBase = class constructor Create; virtual; end; TDerived

Re: [fpc-pascal] Understanding virtual methods

2013-08-20 Thread Xiangrong Fang
Thanks. Do you mean that the rules I see in the document apply to NORMAL virtual methods, but not virtual constructors? Also, I have a related question: it seems that to override methods in ancestor it is required that the method has same signature, however reintroduce will not have such

Re: [fpc-pascal] Understanding virtual methods

2013-08-20 Thread Martin
On 20/08/2013 07:32, Xiangrong Fang wrote: Thanks. Do you mean that the rules I see in the document apply to NORMAL virtual methods, but not virtual constructors? They apply to constructors too. But... A virtual/overridden method is looked up based on the class used in code TDerived.create;

Re: [fpc-pascal] Understanding virtual methods

2013-08-20 Thread Martin
On 20/08/2013 07:32, Xiangrong Fang wrote: Thanks. Do you mean that the rules I see in the document apply to NORMAL virtual methods, but not virtual constructors? for all the rest, you should look for a tutorial. it is to complex for the mailing list

Re: [fpc-pascal] Understanding virtual methods

2013-08-20 Thread Antonio Fortuny
Le 20/08/2013 07:34, Xiangrong Fang a crit: Hi Flavio, Your findings confirmed mine, but not telling me why? It seems that the "virtual" keyword has no use at all! To confirm this, I just removed the

Re: [fpc-pascal] Understanding virtual methods

2013-08-20 Thread Flávio Etrusco
On Tue, Aug 20, 2013 at 2:34 AM, Xiangrong Fang xrf...@gmail.com wrote: Hi Flavio, Your findings confirmed mine, but not telling me why? I don't know why, maybe FPC used to be more strict about the use of inherited, or the docs are simply wrong. It seems that the virtual keyword has no use

Re: [fpc-pascal] Understanding virtual methods

2013-08-20 Thread Sven Barth
Am 20.08.2013 09:36 schrieb Antonio Fortuny a.fort...@sitasoftware.lu: Le 20/08/2013 07:34, Xiangrong Fang a écrit : Hi Flavio, Your findings confirmed mine, but not telling me why? It seems that the virtual keyword has no use at all! To confirm this, I just removed the inherited call in

Re: [fpc-pascal] Understanding virtual methods

2013-08-20 Thread Antonio Fortuny
Le 20/08/2013 14:34, Sven Barth a crit: This is not same as the description in: http://www.freepascal.org/docs-html/ref/refsu26.html BTW, the above documents are talking about objects, but I am using classes, is there any

Re: [fpc-pascal] Understanding virtual methods

2013-08-20 Thread Sven Barth
Am 20.08.2013 14:39 schrieb Antonio Fortuny a.fort...@sitasoftware.lu: Le 20/08/2013 14:34, Sven Barth a écrit : This is not same as the description in: http://www.freepascal.org/docs-html/ref/refsu26.html BTW, the above documents are talking about objects, but I am using classes, is

Re: [fpc-pascal] Understanding virtual methods

2013-08-20 Thread Xiangrong Fang
Hi Sven, Thank you for comment :) I am interested in a high level description of how these concepts (virtual / reintroduce / overloading) differs and how they affect programming, and I am currently not running into trouble, just try to get a better understanding of the language. I'll explain

Re: [fpc-pascal] Understanding virtual methods

2013-08-20 Thread Sven Barth
On 20.08.2013 15:39, Xiangrong Fang wrote: 1) I didn't notice that my question are related to modes of fpc, i.e. turbo-pascal/delphi/objfpc.If they are different, I would like to know more details, and I am more interested in objfpc mode, not those compatibility modes. It has nothing to

[fpc-pascal] Understanding virtual methods

2013-08-19 Thread Xiangrong Fang
Hi All, I am reading this document: http://www.freepascal.org/docs-html/ref/refsu29.html and doing an experiment with the following code: program project1; {$mode objfpc}{$H+} type TBase = class constructor Create; virtual; end; TDerived = class(TBase) constructor Create;

Re: [fpc-pascal] Understanding virtual methods

2013-08-19 Thread Flávio Etrusco
On Mon, Aug 19, 2013 at 10:44 PM, Xiangrong Fang xrf...@gmail.com wrote: Hi All, I am reading this document: http://www.freepascal.org/docs-html/ref/refsu29.html and doing an experiment with the following code: program project1; {$mode objfpc}{$H+} type TBase = class constructor

Re: [fpc-pascal] Understanding virtual methods

2013-08-19 Thread Xiangrong Fang
Hi Flavio, Your findings confirmed mine, but not telling me why? It seems that the virtual keyword has no use at all! To confirm this, I just removed the inherited call in TDerived, then re-run the program with or without virtual/override, the result is exactly same, i.e. with c2 (declared as