Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Avoid (hide) Constructor Create?

48 views
Skip to first unread message

IvKo

unread,
May 19, 2008, 12:29:55 PM5/19/08
to
Hi,

I need to hide constructor Create from base class TObject, when children
class have more that one constructor.

Example:

TObjectA = class(TObject)
public
Construtor Create(AAA:string); overload;
Construtor Create(BBB:integer); overload;
end;


In this case when I see TObject.Create also as available constructor for
TObjectA.

Example:
var
CC:TObjectA;
begin
CC:=TObjectA.Create; <= I need to hide this constructor. TObjectA.Create is
extremely unacceptable for me.

Any idea - how??

Regards,
Iv


John Herbster

unread,
May 19, 2008, 12:47:11 PM5/19/08
to

"IvKo" <invalid@email> wrote

> I need to hide constructor Create from base class TObject, when children
> class have more that one constructor.

> Example:

> TObjectA = class(TObject)
> public
> Construtor Create(AAA:string); overload;
> Construtor Create(BBB:integer); overload;
> end;

> In this case when I see TObject.Create also as available constructor for
> TObjectA.

> Example:
> var
> CC:TObjectA;
> begin
> CC:=TObjectA.Create; <= I need to hide this constructor.

> // TObjectA.Create is extremely unacceptable for me.

> Any idea - how??

IvKo,
From whom do want to hide the TObject.Create constructor?
In what context, do you want to hide the constructor?
Regards, JohnH

danny heijl

unread,
May 19, 2008, 2:30:28 PM5/19/08
to
IvKo schreef:

> I need to hide constructor Create from base class TObject, when children
> class have more that one constructor.

http://www.delphi3000.com/articles/article_990.asp?SK=

danny
---

Peter Below (TeamB)

unread,
May 19, 2008, 2:31:26 PM5/19/08
to
IvKo wrote:

You can only hide an ancestor method with public visibility if you
provide a new version of it, e.g.

TObjectA = class(TObject)
public
Constructor Create(AAA:string); overload;
Constructor Create(BBB:integer); overload;
Constructor Create; overload;
end;

with an implementation like

constructor.TObjectA.Create;
begin
raise Exception.Create('Don''t use this constructor you dummy!');
end;

--
Peter Below (TeamB)
Don't be a vampire (http://slash7.com/pages/vampires),
use the newsgroup archives :
http://www.tamaracka.com/search.htm
http://groups.google.com

IvKo

unread,
May 19, 2008, 3:11:37 PM5/19/08
to
Thank you.

"Peter Below (TeamB)" <no...@nomail.please> wrote in message
news:xn0fqdlg...@newsgroups.borland.com...

0 new messages