[fpc-pascal]OO in Pascal

Jonas Maebe jmaebe at elis.rug.ac.be
Sun Sep 29 15:51:51 CEST 2002


On Sat, 28 Sep 2002, John Coppens wrote:

> > public class A {
> > 	public void start {
> > 		//...
> > 	}
> > }
> > 
> > public class B extends A {
> > 	public void start {
> > 		Super.start();
> > 		//...
> > 	}
> > }
> > 
> > Can this be done in FPC ?
> 
> Do you mean heritage? Like this:
> 
> type
>   A = class
>     procedure start;
>   end;
> 
>   B = class (A)
>     procedure start;
>   end;

Note that to get exactly the same behaviour a in Java in all cases, you 
have to change the declaration like this:

type
  A = class
    procedure start; virtual;
  end; 

  B = class (A)
    procedure start; override;
  end;

In the particular case mentioned above, it doesn't matter, but in general 
it will.


Jonas





More information about the fpc-pascal mailing list