Recent

Author Topic: How can I override methots in my class?  (Read 4527 times)

BlueIcaro

  • Hero Member
  • *****
  • Posts: 820
    • Blog personal
How can I override methots in my class?
« on: September 21, 2010, 04:19:19 pm »
Hello, I have a class like this:

Quote
Type tMyClass = Class
   Private
    (...)
   Public
      Constructor Create;
      Procedure Blabla;
end;

Well, with this I have a Class, and I can write:

Quote
  MiClase := TMyClass.Create;
  MiClase.Blaba;

But How Can I override the constructor, and the procedure, and have some thing like this:

Quote
  Constructor Create (Param1:String);
  Procedure Blabla (Param : Integer);

I know, this you can do it in C#, but I want How can I do in FreePascal?

Thanks
/BlueIcaro


JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4570
  • I like bugs.
Re: How can I override methots in my class?
« Reply #1 on: September 21, 2010, 05:38:51 pm »
Just add "overload;" keyword to the end of functions with same name but different parameter signature.

Juha
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

BlueIcaro

  • Hero Member
  • *****
  • Posts: 820
    • Blog personal
Re: How can I override methots in my class?
« Reply #2 on: September 21, 2010, 06:09:40 pm »
Just add "overload;" keyword to the end of functions with same name but different parameter signature.

Juha


Thank you, it's works!!  :D

Well, Now I think it was fool question, I need read more Object Pascal  :-[

/BlueIcaro

Leledumbo

  • Hero Member
  • *****
  • Posts: 8801
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: How can I override methots in my class?
« Reply #3 on: September 23, 2010, 11:57:39 am »
Just want to correct your term, it's overloading, not overriding.

 

TinyPortal © 2005-2018