Doubts - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Doubts

How to create control array in delphi?
What is the actual power of protected data members?
What we can't achieve with public which we can achieve with published?

Comments

  • zibadianzibadian Posts: 6,349Member
    : How to create control array in delphi?
    : What is the actual power of protected data members?
    : What we can't achieve with public which we can achieve with published?
    :
    Array:
    [code]
    var
    MyControls: array[0..10] of TControl;
    [/code]
    Protected:
    Protected members are visible inside the unit, in which the object has been declared and all the descendants of the object. This gives you the ability to design "private" members, which are public to the various descendants. Nearly all of the controls make use of this. For example the TMemo, publishes all the protected properties of the TCustomMemo.
    Public/Published:
    Published properties appear in the Object Inspector. Public don't. Thus published properties have only meaning in components.
  • Chaitanya_PuneChaitanya_Pune Posts: 87Member
    : : How to create control array in delphi?
    : : What is the actual power of protected data members?
    : : What we can't achieve with public which we can achieve with published?
    : :
    : Array:
    : [code]
    : var
    : MyControls: array[0..10] of TControl;
    : [/code]
    : Protected:
    : Protected members are visible inside the unit, in which the object has been declared and all the descendants of the object. This gives you the ability to design "private" members, which are public to the various descendants. Nearly all of the controls make use of this. For example the TMemo, publishes all the protected properties of the TCustomMemo.
    : Public/Published:
    : Published properties appear in the Object Inspector. Public don't. Thus published properties have only meaning in components.
    :
    ----------------------------------------------------------------------
    Thanks Zibadian.
    Sorry for the mistake.
    Actually I wanted to know where the use of Published is must and its power.

    I also have some doubts regarding Class reference and Class Method.

    Whether the class method are same as static functions in other OOP or is there any difference?

    What is the practical use of Class reference?



  • zibadianzibadian Posts: 6,349Member
    : : : How to create control array in delphi?
    : : : What is the actual power of protected data members?
    : : : What we can't achieve with public which we can achieve with published?
    : : :
    : : Array:
    : : [code]
    : : var
    : : MyControls: array[0..10] of TControl;
    : : [/code]
    : : Protected:
    : : Protected members are visible inside the unit, in which the object has been declared and all the descendants of the object. This gives you the ability to design "private" members, which are public to the various descendants. Nearly all of the controls make use of this. For example the TMemo, publishes all the protected properties of the TCustomMemo.
    : : Public/Published:
    : : Published properties appear in the Object Inspector. Public don't. Thus published properties have only meaning in components.
    : :
    : ----------------------------------------------------------------------
    : Thanks Zibadian.
    : Sorry for the mistake.
    : Actually I wanted to know where the use of Published is must and its power.
    :
    : I also have some doubts regarding Class reference and Class Method.
    :
    : Whether the class method are same as static functions in other OOP or is there any difference?
    :
    : What is the practical use of Class reference?
    :
    :
    :
    :
    Published is a must if you want a property to appear in the object inspector, which is only if you're making your own components, which are being edited at design time in the Delphi IDE.

    Class methods operate on class references. Static methods in other OOP languages are ways to create "procedures". For example: the Math object in Java is basically a way to create maths functions in an OOP way.

    A class reference gives the ability to override objects, which are created in 3rd-party units, or in library units. An example of it is the CreateForm(). This method in the TApplication object can create any component or descendant, without the need to override it specifically for forms or datamodules. Class references also allow programmers to create object factories: objects which automatically create other objects without the programmer to call the constructor.
Sign In or Register to comment.