Sign in Join

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

Mailing lists / fpc-pascal / 2016-10

Class helper method overloading ?

4 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

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

LacaK

Hi,

is there posibility introduce in class helper method with same name like in base class ?

For example:

TSQLQueryHelper = class helper for TSQLQuery
   public
     procedure ExecSQL(const ASQL: string; const Args: array of const);
overload;
end;
procedure TSQLQueryHelper.ExecSQL(const ASQL: string; const Args: array
of const);
begin
   SQL.Text := Format(ASQL, Args);
   ExecSQL; // here I want call ExecSQL of TSQLQuery, but compiler
complains about wrong number of parameters
end;
When I use:
   inherited ExecSQL;

it compiles (and why is there need to use "inherited", when I use overload and there exists method ExecSQL without parameters?)

, but later I get again error "Wrong number of parameters specified for call to "ExecSQL"",
when I want use ExecSQL('',[]) in instance of TSQLQuery

Thanks

-Laco.

Reply by email

Michael Van Canneyt
to LacaK
LacaK wrote 30 lines
Hi, is there posibility introduce in class helper method with same name like in base class ? For example: TSQLQueryHelper = class helper for TSQLQuery public procedure ExecSQL(const ASQL: string; const Args: array of const); overload; end; procedure TSQLQueryHelper.ExecSQL(const ASQL: string; const Args: array of const); begin SQL.Text := Format(ASQL, Args); ExecSQL; // here I want call ExecSQL of TSQLQuery, but compiler complains about wrong number of parameters end; When I use: inherited ExecSQL; it compiles (and why is there need to use "inherited", when I use overload and there exists method ExecSQL without parameters?) , but later I get again error "Wrong number of parameters specified for call to "ExecSQL"", when I want use ExecSQL('',[]) in instance of TSQLQuery

Why not create a descendent class simply ?

Michael.

Reply by email

LacaK
to Michael Van Canneyt
Why not create a descendent class simply ?
Yes it is what I have used ;-)
I have one instance of variable:
{$IFDEF xxx}
   Query: TRemoteQuery;
{$ELSE}
   Query: TSQLQuery;
{$ENDIF}
TRemoteQuery has ExecSQL(A,B) as own method.
I wanted use TSQLQuery but only difference is missing ExecSQL(A,B) so I
want create helper and add this missing method.

I know that I can solve it with descendant, which I did before, but I am still interesting if it is possible do with helper and in general if there can be overloaded method ...

-Laco.

Reply by email

LacaK
to LacaK: is there posibility introduce in class helper method with same name like in base class ?…

http://bugs.freepascal.org/view.php?id=30761

Show quoted text 35 lines
Hi, is there posibility introduce in class helper method with same name like in base class ? For example: TSQLQueryHelper = class helper for TSQLQuery public procedure ExecSQL(const ASQL: string; const Args: array of const); overload; end; procedure TSQLQueryHelper.ExecSQL(const ASQL: string; const Args: array of const); begin SQL.Text := Format(ASQL, Args); ExecSQL; // here I want call ExecSQL of TSQLQuery, but compiler complains about wrong number of parameters end; When I use: inherited ExecSQL; it compiles (and why is there need to use "inherited", when I use overload and there exists method ExecSQL without parameters?) , but later I get again error "Wrong number of parameters specified for call to "ExecSQL"", when I want use ExecSQL('',[]) in instance of TSQLQuery Thanks -Laco.

Reply by email