[fpc-pascal] Wrong constructor returning the right object

2014-02-23 Thread Mark Morgan Lloyd
I think I've sorted this but I'd appreciate being kicked if it looks like I'm doing something badly wrong. What determines the constructor that's called when an object's created? I've got a couple of classes defined like this: TB5500BaseUnit= class(TObject) constructor

Re: [fpc-pascal] Wrong constructor returning the right object

2014-02-23 Thread Jeppe Græsdal Johansen
Den 23-02-2014 15:26, Mark Morgan Lloyd skrev: I think I've sorted this but I'd appreciate being kicked if it looks like I'm doing something badly wrong. What determines the constructor that's called when an object's created? I've got a couple of classes defined like this: TB5500BaseUnit=

Re: [fpc-pascal] Wrong constructor returning the right object

2014-02-23 Thread Mark Morgan Lloyd
Jeppe Græsdal Johansen wrote: I find that if I explicitly decorate TB5500BaseUnit.Create() as virtual and TB5500SPOUnit.Create() as override then TB5500SPOUnit.Create() is called correctly. I didn't think this was necessary, but on reflection I assume that it's because u is declared as a

Re: [fpc-pascal] Wrong constructor returning the right object

2014-02-23 Thread Marco van de Voort
In our previous episode, Mark Morgan Lloyd said: That logical, since the constructors are not an virtual; and override; pair. I find that if I explicitly decorate TB5500BaseUnit.Create() as virtual and TB5500SPOUnit.Create() as override then TB5500SPOUnit.Create() is called correctly.

Re: [fpc-pascal] Wrong constructor returning the right object

2014-02-23 Thread Mark Morgan Lloyd
Marco van de Voort wrote: In our previous episode, Mark Morgan Lloyd said: That logical, since the constructors are not an virtual; and override; pair. I find that if I explicitly decorate TB5500BaseUnit.Create() as virtual and TB5500SPOUnit.Create() as override then TB5500SPOUnit.Create()

Re: [fpc-pascal] Wrong constructor returning the right object

2014-02-23 Thread Marco van de Voort
In our previous episode, Mark Morgan Lloyd said: I didn't think this was necessary, _why_ did you think this? In part, because the documentation on method declarations at http://www.freepascal.org/docs-html/ref/refsu25.html#x66-730005.5.1 explicitly allows a virtual method

Re: [fpc-pascal] Wrong constructor returning the right object

2014-02-23 Thread Mark Morgan Lloyd
Marco van de Voort wrote: In our previous episode, Mark Morgan Lloyd said: I didn't think this was necessary, _why_ did you think this? In part, because the documentation on method declarations at http://www.freepascal.org/docs-html/ref/refsu25.html#x66-730005.5.1 explicitly allows a

Re: [fpc-pascal] Wrong constructor returning the right object

2014-02-23 Thread Jeppe Græsdal Johansen
Den 23-02-2014 17:03, Mark Morgan Lloyd skrev: Marco van de Voort wrote: In our previous episode, Mark Morgan Lloyd said: That logical, since the constructors are not an virtual; and override; pair. I find that if I explicitly decorate TB5500BaseUnit.Create() as virtual and