Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2002-09

OO in Pascal

3 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

James Mills

In java you can do this...

public class A {
public void start {

		//...
	}

}

public class B extends A {
public void start {

		Super.start();
		//...
	}

}

Can this be done in FPC ?

cheers
James

Reply by email

John Coppens
to James Mills
Show quoted text 16 lines
In java you can do this... 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;

in the implementation you can

  procedure B.start;
  begin
    inherited A;
  end;

John

Show quoted text 7 lines
cheers James _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Jonas Maebe
to John Coppens
John Coppens wrote 25 lines
> 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

Reply by email