Re: [fpc-pascal] Inherited and not virtual/overridden procedures

2013-06-12 Thread Bart
On 6/12/13, Jonas Maebe wrote: > Now change the variable type to TFoo but keep instantiating it using > TFooChild.Create (like I originally suggested). Having that work is > the whole point of polymorphism and why virtual/override exist. I didn't even know that was possible OK now I see the

Re: [fpc-pascal] Inherited and not virtual/overridden procedures

2013-06-12 Thread Juha Manninen
On Wed, Jun 12, 2013 at 2:39 PM, Max Vlasov wrote: > Overall looking at all cases I think this keyword can be considered as a > good universal prefix excluding the context of the existing class working > with methods and properties. Even looking at the name it has more to do with > INHERITance tha

Re: [fpc-pascal] Inherited and not virtual/overridden procedures

2013-06-12 Thread Jonas Maebe
On 12 Jun 2013, at 13:33, Bart wrote: On 6/12/13, Jonas Maebe wrote: So that it would still have the same behaviour if you changed the variable declaration to var FooChild: TFoo; If I change FooChild to TFoo (and instantiate with TFoo.Create) the Now change the variable type to TFoo

Re: [fpc-pascal] Inherited and not virtual/overridden procedures

2013-06-12 Thread Max Vlasov
On Wed, Jun 12, 2013 at 2:12 AM, Bart wrote: > > I thought that if I had a subclass that inherited form a parentclass, > and both have a method with the same name (Bar), then the method of > the subclass hid the method of the parentclass, and you could not call > inherited Bar in the subclass. >

Re: [fpc-pascal] Inherited and not virtual/overridden procedures

2013-06-12 Thread Bart
On 6/12/13, Jonas Maebe wrote: > So that it would still have the same behaviour if you changed the variable > declaration to > > var > FooChild: TFoo; If I change FooChild to TFoo (and instantiate with TFoo.Create) the outut is always the same, wether or not I use virtual for TFoo.Bar and weth

Re: [fpc-pascal] Inherited and not virtual/overridden procedures

2013-06-11 Thread Jonas Maebe
On 12 Jun 2013, at 00:12, Bart wrote: > var > FooChild: TFooChild; > > begin > FooChild := TFooChild.Create; > FooChild.Bar; > FooChild.Free; > end. > > To my surprise this compiles without any warning or error. > It outputs: > C:\Users\Bart\LazarusProjecten\ConsoleProjecten>test > TFoo.Bar

[fpc-pascal] Inherited and not virtual/overridden procedures

2013-06-11 Thread Bart
Hi, I thought that if I had a subclass that inherited form a parentclass, and both have a method with the same name (Bar), then the method of the subclass hid the method of the parentclass, and you could not call inherited Bar in the subclass. More specifically I was under the impression that you