Kev siv tus neeg teb xov tooj tshiab yog dab tsi?
Kev siv tus neeg teb xov tooj tshiab yog dab tsi?

Video: Kev siv tus neeg teb xov tooj tshiab yog dab tsi?

Video: Kev siv tus neeg teb xov tooj tshiab yog dab tsi?
Video: Qhia saib yus tus hlub lub xov tooj seb nws kov txog dab tsi thaum yus nyob deb 2024, Tej zaum
Anonim

Lub hom phiaj tseem ceeb ntawm tus neeg ua haujlwm tshiab yog faib lub cim xeeb rau qhov sib txawv lossis ib yam khoom thaum lub sijhawm ua haujlwm. Nws yog siv tsis yog malloc() muaj nuj nqi. Thaum twg tus neeg ua haujlwm tshiab yog siv, cov variables/objects raug suav hais tias yog pointers rau lub cim xeeb qhov chaw faib rau lawv.

Cov lus nug tseem yog, tus neeg teb xov tooj tshiab piav qhia li cas nrog piv txwv?

Cov tus neeg ua haujlwm tshiab qhia txog kev thov rau kev faib cov cim xeeb ntawm Heap. Yog muaj kev nco txaus, tus neeg ua haujlwm tshiab pib lub cim xeeb thiab xa rov qab qhov chaw nyob ntawm qhov kev faib tshiab tshiab thiab pib lub cim xeeb rau tus taw tes hloov pauv.

Kuj Paub, tus neeg teb xov tooj tshiab rov qab los hauv C ++ yog dab tsi? Cov C++ tus neeg ua haujlwm tshiab ua tseeb rov qab los qhov chaw nyob ntawm qhov khoom tshiab tsim. Cov tus neeg ua haujlwm tshiab ua tsis tsim ib tus pointer sib txawv. Nws faib ib lub cim xeeb, hu rau cov neeg tsim khoom (yog tias muaj), thiab rov qab los rau koj qhov chaw nyob ntawm block of memory. Ib qho kev qhia hauv C++ muaj tus nqi thiab hom ntaub ntawv.

Ib tug kuj yuav nug, dab tsi yog lub hom phiaj ntawm tus tshiab thiab tshem tawm tus neeg teb xov tooj hauv C ++?

C++ txhawb dynamic faib thiab deallocation ntawm cov khoom siv lub tshiab thiab rho tawm tus neeg teb xov tooj . Cov no cov neeg ua haujlwm faib lub cim xeeb rau cov khoom los ntawm lub pas dej ua ke hu ua lub khw dawb. Cov tus neeg ua haujlwm tshiab hu rau qhov tshwj xeeb muaj nuj nqi tus neeg ua haujlwm tshiab , thiab cov rho tawm tus neeg teb xov tooj hu rau qhov tshwj xeeb muaj nuj nqi tus neeg teb xov tooj rho tawm.

Tus neeg teb xov tooj tshiab thiab rho tawm yog dab tsi?

- tshiab thiab rho tawm tus neeg teb xov tooj yog muab los ntawm C ++ rau runtime nco kev tswj. Lawv yog siv rau kev faib dynamic thiab pub dawb ntawm lub cim xeeb thaum lub program tab tom ua haujlwm. - Cov tus neeg ua haujlwm tshiab faib lub cim xeeb thiab xa rov qab tus pointer rau qhov pib ntawm nws. Cov rho tawm tus neeg teb xov tooj frees nco yav tas los faib siv tshiab.

Pom zoo: