Recent

Author Topic: The Interfaces  (Read 865 times)

pascal111

  • Sr. Member
  • ****
  • Posts: 284
  • Un trabajo en equipo para programas serias.
The Interfaces
« on: May 28, 2021, 02:17:23 pm »
أُريدُ توضيحاً أكثر لماهيّة الـ Interfaces والوارد تعريفها على هذا الرابط https://www.freepascal.org/docs-html/current/ref/refse44.html#x97-1210007.1 وما هي أهميّة أو فائدة الـ Interfaces أي لماذا نحتاجها؟

google translate:

"I want a more clarification of what Interfaces are, and they can be defined at this link. https://www.freepascal.org/docs-html/current/ref/refse44.html#x97-1210007.1 And what is the importance or usefulness of Interfaces That is, why do we need it?"

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 7285
  • Debugger - SynEdit - and more
    • wiki
Re: The Interfaces
« Reply #1 on: May 28, 2021, 02:41:46 pm »
http://www.delphibasics.co.uk/Article.asp?Name=Interface

Read the top.

Then imagine you have a function, that is not interested if the object is a car or a washing machine. The subroutine only wants to know about recycling.
Then you can pass the interface to the subroutine.

Otherwise you pass a TObject, and start doing: "if obj is TCar ... if obj is TWashingMachine..."
« Last Edit: May 28, 2021, 02:46:00 pm by Martin_fr »

pascal111

  • Sr. Member
  • ****
  • Posts: 284
  • Un trabajo en equipo para programas serias.
Re: The Interfaces
« Reply #2 on: May 28, 2021, 03:43:00 pm »
http://www.delphibasics.co.uk/Article.asp?Name=Interface

Read the top.

Then imagine you have a function, that is not interested if the object is a car or a washing machine. The subroutine only wants to know about recycling.
Then you can pass the interface to the subroutine.

Otherwise you pass a TObject, and start doing: "if obj is TCar ... if obj is TWashingMachine..."

كلامكـ لهُ علاقة بالسؤال التالي ،فلماذا في أحد أكواد هذا الرابط التالي https://www.freepascal.org/docs-html/current/ref/refse47.html#x100-1240007.4 تمّ الإعلان عن مُتغيّر من نوع الـ interface ثمّ تمّ شحنه بعمل نُسخة من الصنف ولماذا لم يحصل العكس بأنّ يُعلن عن المُتغيّر كمتغيّر صنف كما هو موضّح في الأكواد التالية:

google translate:

"Your speech is related to the following question, so why in one of the codes for this following link https://www.freepascal.org/docs-html/current/ref/refse47.html#x100-1240007.4 A variant "it's declared" of The type of interface was then charged by making a copy of the class. Why did the opposite not happen? That the variable is declared as a class variable as shown in the following codes:"

Code: Pascal  [Select][+][-]
  1. var  
  2.   Child: IChildInterface;  
  3.  
  4. begin  
  5.   Child := TImplementor.Create;
  6.  

بدلاً من:

google translate:

"instead of:"

Code: Pascal  [Select][+][-]
  1. var  
  2.   Child: TImplementor;  
  3.  
  4. begin  
  5.   Child := TImplementor.Create;
  6.  
  7.  
« Last Edit: May 28, 2021, 03:44:46 pm by pascal111 »

 

TinyPortal © 2005-2018