Vim li cas Dynamic binding tseem ceeb hauv kev siv polymorphism?
Vim li cas Dynamic binding tseem ceeb hauv kev siv polymorphism?

Video: Vim li cas Dynamic binding tseem ceeb hauv kev siv polymorphism?

Video: Vim li cas Dynamic binding tseem ceeb hauv kev siv polymorphism?
Video: Koj yog luag tus los kuv tseem nco. 4/27/2018 2024, Kaum ib hlis
Anonim

Dynamic khi tso cai rau ib tug tswv cuab muaj nuj nqi hu kom daws tau lub sij hawm khiav, raws li run-time hom ntawm cov khoom siv. Qhov no tso cai rau txhua tus neeg siv-txhais chav kawm nyob rau hauv ib qho qub txeeg qub teg hierarchy kom muaj qhov sib txawv kev siv ntawm ib qho haujlwm tshwj xeeb.

Ua raws li qhov kev pom no, dab tsi yog polymorphism piav qhia lub luag haujlwm dynamic binding plays hauv kev siv ntawm polymorphism?

Qhov no yog qhov peb hu ua static kev khi : cov kev khi ntawm cov npe tshwm sim ntawm lub sijhawm sib sau (piv txwv li, zoo li qub). Xws li ib tug mechanism yog hu ua dynamic khi : cov kev khi lub npe rau ib kev siv tshwm sim thaum lub sijhawm khiav (piv txwv li, dynamic ). Dynamic khi yog tsim nyog rau object-oriented programming lus rau siv polymorphism.

Ib yam li ntawd, kev siv dynamic binding yog dab tsi? Static kev khi siv hom (chav kawm hauv Java) cov ntaub ntawv rau kev khi thaum dynamic khi siv cov khoom los daws kev khi . Cov txheej txheem overloaded yog sib koom nrog siv static kev khi thaum overridden txoj kev yog sib koom siv dynamic khi ntawm runtime.

Tom qab ntawd, lo lus nug yog, puas yog dynamic binding polymorphism?

Polymorphism hauv Java muaj ob hom: Compile lub sijhawm polymorphism (static kev khi ) thiab Runtime polymorphism ( dynamic khi ). Ib qho piv txwv tseem ceeb ntawm polymorphism yog li cas cov niam txiv chav hais txog cov khoom hauv chav kawm me nyuam. Qhov tseeb, txhua yam khoom uas txaus siab ntau dua ib qho kev sib raug zoo IS-A polymorphic nyob rau hauv qhov.

Yuav ua li cas Dynamic binding muaj txiaj ntsig hauv oops?

Dynamic khi ua tiav siv cov haujlwm virtual. Base class pointer taw tes rau cov khoom siv hauv chav kawm. Thiab ib qho kev ua haujlwm tau tshaj tawm virtual hauv cov chav kawm hauv paus, tom qab ntawd cov haujlwm sib txuam raug txheeb xyuas thaum lub sijhawm ua haujlwm siv lub rooj nkag virtual. Yuav ua li cas cov ntsiab lus hla hauv ib qho object-oriented programming lus ( OOP )?

Pom zoo: