Dab tsi yog chav kawm paub daws teeb meem C ++?
Dab tsi yog chav kawm paub daws teeb meem C ++?

Video: Dab tsi yog chav kawm paub daws teeb meem C ++?

Video: Dab tsi yog chav kawm paub daws teeb meem C ++?
Video: TSIS YOG PEB UA HAUJ LWM ZOO .\\ N.TSHUAV NUM |\ N.IAM VAJ XOB \\ N.TXOOV KAV NKAUJ 2023 2024, Kaum ib hlis
Anonim

Cov chav kawm Abstract ( C ++)

A chav kawm uas muaj tsawg kawg yog ib qho kev ua haujlwm dawb huv yog suav tias yog ib qho chav kawm abstract . Cov chav kawm tau los ntawm chav kawm abstract yuav tsum ua raws li kev ua haujlwm dawb huv virtual lossis lawv, ib yam nkaus, yog chav kawm paub daws teeb meem.

Ua li no, siv cov chav kawm paub daws teeb meem hauv C ++ yog dab tsi?

Cov lub hom phiaj ntawm ib chav kawm abstract yog los txheeb xyuas cov txheej txheem sib xws rau cov txheej txheem subclasses. Qhov no yog qhov muaj txiaj ntsig thaum txhais cov khoom uas qhia cov lej, abstract cov tswv yim, thiab lwm yam. sim kom instantiate ib chav kawm abstract ib txwm yuav ua rau muaj qhov yuam kev compiler.

Qhov thib ob, dab tsi yog chav kawm abstract piav nrog piv txwv? A chav kawm uas tau tshaj tawm tias siv abstract ” lo lus tseem ceeb yog hu ua chav kawm abstract . Nws tuaj yeem muaj abstract txoj kev (txoj kev tsis muaj lub cev) nrog rau cov txheej txheem ua vaj tse (txoj kev tsis tu ncua nrog lub cev). Ib chav kawm abstract tsis tuaj yeem instantiated, uas txhais tau hais tias koj tsis raug tso cai los tsim ib yam khoom ntawm nws.

Ib yam li ntawd, nws tau nug, dab tsi yog chav kawm paub daws teeb C ++?

Ib chav kawm abstract yog a chav kawm uas yog tsim los tshwj xeeb siv los ua lub hauv paus chav kawm . Ib chav kawm abstract muaj tsawg kawg yog ib qho kev ua haujlwm dawb huv virtual. Koj tshaj tawm qhov kev ua haujlwm dawb huv virtual los ntawm kev siv tus qauv ntshiab (= 0) hauv kev tshaj tawm ntawm tus tswv cuab virtual hauv chav kawm tshaj tawm.

Dab tsi yog chav kawm paub daws teeb meem thiab chav ua vaj tse hauv C ++?

Ib chav kawm abstract yog txhais tau tias yog siv los ua lub hauv paus chav kawm qhov twg qee qhov lossis tag nrho cov haujlwm tau tshaj tawm tias yog virtual nkaus xwb thiab yog li tsis tuaj yeem ua tam sim. A chav ua vaj tse yog ib qho dog dig chav kawm uas tsis muaj lub luag haujlwm virtual nkaus xwb thiab yog li tuaj yeem ua tau sai.