
placement vaakyaghadana

sii + + prograaming bhashayil, playsment vaakyaghadana prograamarmaare vyakthigatha vasthukkalude memory maanejment vyakthamaayi vyakthamakkaan anuvadikkunnu-i.iii. avarude "sthaanam" oormmayil. saadhaaranayaayi, oru object chalanathmakamaayi srishtikkumbol, oru alokkeshan function aavashyappedunnathu athu objectinaayi memory anuvadikkukayum puthuthayi anuvadicha memmarikkullil object aarambikkukayum cheiyunna tharatthilaanu. alokkeshan functionilekku adhika aargyumentukal nalkaan playsment vaakyaghadana prograamare anuvadikkunnu. object aarambikkaan kazhiyunna anuyojyamaaya sambharana mekhalayilekku oru pooyintar vitharanam cheyyuka ennathaanu oru saadhaarana upayogam, angane memory alokkeshan object nirmmaanatthil ninnu verthirikkunnu.
cocks 1, cocks 2 oopparettarmaarudeyum functionukaludeyum "placement" pathippukale placement cocks 1, placement cocks 2 ennu vilikkunnu. oru cocks 1 "expression", placement allengil mattenthenkilum, oru alokkettar function ennum ariyappedunna cocks 1 "function" ennu vilikkunnu, athinte peru cocks 7 aanu. athupole, oru cocks 2 "expression" oru cocks 2 "function" ennu vilikkunnu, ithu delocator function ennum ariyappedunnu, athinte peru kookk 10 aanu.
placement vaakyaghadana upayogikkunna eathoru kokvi _ 1 padaprayogavum oru placement kokvi _ 1 padaprayogamaanu, koodaathe nirbandhitha aadya paaraamettarinekkaal (std:: side _ t) kooduthal edukkunna eathu kokvi _ 7 allengil kokvi _ 10 function oru puthiya placement allengil placement illaathaakkal functionaanu. oru puthiya playsment function rund inputt paaraamettarukal edukkunnu std:: sieze _ t, shoonyamaaya *.
charithram.
sii + +-nte muun pathippukalil "puthiya sthaanam" ennonnilla; pakaram, samanamaaya phalam nedunnathinu developermaar nirmmathaakkalkkullil "ithu" ennathinu vyakthamaaya assainment upayogichu. eee sambradaayam pinneedu nirthalaakkukayum "sii + + prograaming bhasha" yude moonnaam pathippil eee saankethikavidya paraamarsikkaathirikkukayum cheythu.
aavishkaarangal.
oru noonn-playsment kokwos _ 1 padaprayogatthinte staanderd sii + + vaakyaghadana ithaanu
placement vaakyaghadana cockways _ 1 keevedinu thottupinnaale oru expression listt cherkkunnu. eee padaprayoga pattikayaanu sthaanam. athil ethra expressionukal venamenkilum adangiyirikkaam.
pravartthanangal.
puthiya playsment functionukal noonn-playsment puthiya functionukalude ovarlodukalaanu. noonn-array, aare kokj _ 1 eksprashanukalkkaayi yathaakramam noonn-placement puthiya functionukalude prakhyapanam ivayaanu
 shoonyamaaya oopparettar puthiya (STD:: sais _ t) throw (STD:: mosham _ alok);
 shoonyamaaya oopparettar puthiya [] (STD:: sais _ t) throw (STD:: mosham _ alok);
staanderd sii + + library eee pravarthanangalkkaayi rund placement ovarlodukal nalkunnu. avarude prakhyapanangal ivayaanu
 shoonyamaaya oopparettar puthiya (STD:: sais _ t, koonst STD:: nottoo _ t &) throw ();
 shoonyamaaya oopparettar puthiya (STD:: valuppam _ t, shoonyamaaya *) throw ();
 shoonyamaaya oopparettar puthiya [] (std:: sais _ t, koonst std:: nothro _ t &) throw ();
 shoonyamaaya oopparettar puthiya [] (STD:: valuppam _ t, shoonyamaaya *) eriyuka ();
ellah ovarlodukalilum, cocew _ 7 functionte aadya paaraameettar stadit sais _ tii tharatthilaanu, ithu function vilikkumbol memmariyude alavu, baittukalil, anuvadikkunnathinu vyakthamaakkunna oru aargyumentayi kaimar. ellah functionukalum tharam shoonyamaayirikkanam *, ithu function anuvadikkunna sambharanathilekkulla oru poyintaraanu.
playsment delete functionukalum undu. avaa noonn-playsment delete functionukalude overload cheytha pathippukalaanu. noonn-playsment delete functionukal ingane prakhyaapikkunnu
 shoonyamaaya oopparettar illaathaakkuka (shoonyamaaya *) eriyuka ();
 shoonyamaaya oopparettar illaathaakkuka [] (shoonyamaaya *) eriyuka ();
staanderd sii + + library eee pravarthanangalkkaayi rund placement ovarlodukal nalkunnu. avarude prakhyapanangal ivayaanu
 void oopparettar illaathaakkuka (void *, koonst stadda nothro _ t &) throw ();
 shoonyamaaya oopparettar illaathaakkuka (shoonyamaaya *, shoonyamaaya *) eriyuka ();
 void oopparettar illaathaakkuka [] (void *, koonst stadit nothro _ t &) throw ();
 shoonyamaaya oopparettar illaathaakkuka [] (shoonyamaaya *, shoonyamaaya *) eriyuka ();
ellah ovarlodukalilum, kokwos _ 10 functionte aadya paaraameettar void * typaanu, ithu neekkamcheyyenda storejinte vilaasamaan.
puthiyathum illaathaakkunnathumaaya functionukalkku, functionukal aagolamaan, oru namespaceilum illa, staatik linkej illa.
upayogikkuka.
placement vaakyaghadanaykku naalu pradhana upayogangalundu sthirasthithi placement, ozhivaakkalukal thadayal, ishtaanusritha alokkettarukal, debugging.
sthirasthithi sthaanam.
adhika shoonyamaaya * paaraameettar upayogikkunna cocks 7, cocks 10 ennivayude placement ovarlodukal sthirasthithi placementinaayi upayogikkunnu, ithu "pooyintar placement" ennum ariyappedunnu. oru sii + + prograaminu pakaram vaykkunnathino override cheiyunnathino anuvadaneeyamallaatha staanderd sii + + libraryude nirvachanangal ivayaanu
sthirasthithi placementinu vividha upayogangalundu.
oru prathyeka hardware vilaasathil oru prathyeka vasthu prathekshikkunna hardwarein puthiya pooyintar placement aavasyamaanennu bjarne stroustrup thante "dhii design aandu evalution oof sii + +" enna pusthakatthil aadyam nireekshichu. oru multiprosessor computerinte niravadhi prosessorukalkkidayil pankittirikkunna oru pradesham polulla oru prathyeka memory eriyayil thaamasikkenda vasthukkalude nirmmaanathinum ithu aavasyamaanu.
ennirunnaalum, mattu upayogangalil oru kanstraktare nerittu vilikkunnathu ulppedunnu, ithu sii + + bhasha anuvadikkunnilla.
sii + + bhasha oru prograamine oru distructore nerittu vilikkaan anuvadikkunnu, koodaathe, oru kokwos _ 2 expression upayogichu object nasippikkaan kazhiyaathathinal, oru pooyintar placement puthiya expression vazhi nirmmicha oru objectine oraal nasippikkunnathu anganeyaan. udaaharanathina
p-> ~ t ();
kesukal upayogikkuka.
oopparettar nyoo memory anuvadikkaan ningal aagrahikkaathappol puthiya playsment upayogikkunnu (ningal athu munkootty anuvadikkukayum ningal avide object sthaapikkaan aagrahikkukayum cheiyunnu), pakshe ningalkk object nirmmikkanam. ithu aavashyamaayi vannekkaavunna saadhaarana saahacharyangalude udaaharanagal ivayaanu
kanstraktar oru prathyeka pravarthanamaanu ennathaanu adisthaana prashnam; athu aarambhikkumbol, oru vasthuvumilla, asamskritha memory maathram. athu poortthiyaakumbozhekkum ningalkk poornnamaayum aarambikkappetta oru object labikkum. athinaal, i) kanstraktarine oru objectil vilikkaan kazhiyilla) ennirunnaalum, athu staatik allatha amgangale axus (aarambikkukayum) cheyyendathundu. ithu kanstraktare nerittu vilikkunnathil pishakaakkunnu. puthiya oopparettarude playsment roopamaanu pariharam.
eee oopparettar thaazhepparayunna reethiyil nadappilaakkunnu
ozhivaakkalukal thadayunnu.
saadhaaranayaayi, labhyamaya ellah memory theernnupokunnathu polulla oru pishak nerittaal (noonn-playsment) puthiya functionukal kokvu _ 27 tharam ozhivaakkunnu. stroustrappinte "anotated sii + + reference maanuval" vazhi functionukal nirvachichathu inganeyalla, marichu sii + + bhasha staanderdais cheythappol standerdisation kammitti varuthiya mattamaayirunnu ithu. oru pishak sambhavikkumbol oru nall pooyintar thirike nalkanamenna functionukalude yadhaartha swabhaavam placement vaakyaghadanayiloode axus cheyyaavunnathaanu.
thangalude prograamukalil ithu cheyyaan aagrahikkunna programmermar sozhs codil staanderd sii + + library header cacos _ 28 ulppeduthanam. eee header aagola coaches _ 29 object prakhyaapikkunnu, ithu coaches _ 30 (headeril prakhyapikkukayum cheiyunnu) tharatthilaanu, ithu overload cheytha puthiya functionukale consted stadda nottoo _ tii & avarude randaamathe paaraameteraayi vilikkaan upayogikkunnu. udaaharanathina
ghadana t {};
int maine () {
 //function oopparettare puthiyath ennu vilikkuka (std:: siez _ t, sthiraamkam std:: nothro _ t &) koodaathe (vijayakaramaanengil) object nirmmikkuka.
 t * p = puthiya (std:: nottoo) t;
 (pii) {
 //sambharanam anuvadikkukayum nirmmaathaavine vilikkukayum cheythu.
 pii illaathaakkuka;
 ) allengil
 ;// oru pishak sambhavichu. sambharanamo nirmmaanamo anuvadichittilla.
 0 thirike nalkuka;
ishtaanusritha alokkettarmaar.
ishtaanusritha alokkettarmarkkum placement vaakyaghadana upayogikkunnu. ithu staanderd sii + + library header kakes _ 28 ll ninnulla alokkettar, delocator functionukalonnum upayogikkunnilla, ennaal programmermar avarude swantham allocation delocation functionukalum ezhuthanam, upayokthaav nirvachicha tharangalkk overload cheyyanam. udaaharanathinu, oraalkk oru memory maanejment klaas inipparayunna reethiyil nirvachikkaam
klaas eiii {
pothujanangal
 shoonyamaaya * anuvadikkuka (std:: valuppam _ t);
 shoonyamaaya dee alokkeshan (shoonyamaaya *);
ishtaanusritha playsment allocation delocation functionukalum inipparayunna reethiyil nirvachikkuka
shoonyamaaya oopparettar puthiyath (STD:: sais _ tii sais, a & arina) {
 refund eriya.(valippam) anuvadikkuka;
shoonyamaaya oopparettar illaathaakkuka (shoonyamaaya * pii, eiii & areena) {
 stadium.delocate (pii);
thaazhepparayunna reethiyil cockways _ 32 klaasinte vyathyastha udaaharanagal upayogichu objectukal anuvadikkunnathinu prograam placement vaakyaghadana upayogikkum
oru aadya _ arane, randaam _ arane;
t * p1 = puthiya (aadya _ areena) t;
t * p2 = puthiya (second _ areena) t;
atharam reethiyil sambharanam anuvadicha oru vasthuvine nasippikkunnathinu kurachu shradha aavasyamaanu. playsment delete expression illaathathinaal, ishtaanusritha delocator abhyarthikkaan oraalkk ithu upayogikkaan kazhiyilla. oraal onnukil ishtaanusritha delocate vilikkunna oru destruction function ezhuthanam, allengil playsment delete functione nerittu oru function kooll aayi vilikkanam.
aadyathethu samanamaayirikkum
shoonyamaaya nasham (tii * pii, eiii & areena) {
 p-> ~ t ();// aadyam distructorine vyakthamaayi vilikkuka.
 stadium.dealocate (pii);// ennittu dealocator functione nerittu vilikkuka.
oru prograamil ninnu inipparayunna reethiyil ithu abhyarthikkum
oru mekhala;
t * p = puthiya (areena) t;
nasippikkuka (pii, areena);
randaamathethil distructor invocation ezhuthukayum prograamilekku function kooll illaathaakkukayum cheyyuka
oru mekhala;
t * p = puthiya (areena) t;
p-> ~ t ();// aadyam distructorine vyakthamaayi vilikkuka.
oopparettar delete (pii, areena);// thudarnnu oopparettar delete (void *, eiii &) vazhi parokshamaayi delocator functione vilikkuka.
object illaathaakkaan oru delete expression upayogikkaan sramikkuka ennathaanu oru saadhaarana pishak. ithu thettaaya kokwos _ 10 function vilikkunnathinu kaaranamaakunnu. eee pishak ozhivakkaan deverst rund thanthrangal shupaarsha cheiyunnu. aadyathethu, eathoru ishtaanusritha alokkettarukalum staanderd sii + + libraryude aagola, noonn-playsment, cockways _ 7 neey aashrayikkunnuvenn urappaakkuka ennathaanu, athinaal sii + + libraryude memory maanejmentine chuttipattiyulla lalithamaaya rapperukal allathe matonnumalla. randaamathethu vyakthigatha klaasukalkkaayi puthiyathum illaathaakkunnathumaaya functionukal srishtikkuka, placement vaakyaghadana upayogikkunathinupakaram klaas function amgangal vazhi memory maanejment ishtaanusrithamaakkuka ennivayaanu.
debugging.
memory alokkeshan parajayappetta sozhs kodinte fayalnaamavum line number print cheyyaan prograamukale praapthamaakkunnathin puthiya playsment oru lalithamaaya debugging upakaranamaayum upayogikkaam. ithinu staanderd sii + + library header coach _ 28 ulppeduthendathilla, ennaal naalu placement functionukal prakhyaapikkunna oru header puthiya padaprayogangalil upayogikkunna coach _ 1 keevedinu oru macro maattisthaapikkalum ulppeduthendathundu. udaaharanathinu, atharam oru thalakkettil inipparayunnava adangiyirikkum
shoonyamaaya oopparettar puthiya (STD:: sais _ tii sais, koonst chaar * phayal, inttu line);
shoonyamaaya oopparettar puthiya [] (STD:: sais _ tii sais, koonst chaar * phayal, inttu line);
void oopparettar illaathaakkuka (void * pii, koonst chaar * phayal, int line);
shoonyamaaya oopparettar illaathaakkuka [] (shoonyamaaya * p, konstaar chaar * phayal, int line);
ithu thaazhepparayunna reethiyil oru prograamil upayogikkum
tii * pii = puthiya tii;
oru apavaadamundaayaal, ishtaanusrithamaayi ezhuthiya playsment puthiya functionukal vitharanam cheytha phayal, line nambar vivarangal enniva upayogichu kaikaaryam cheyyum. udaaharanathina
klaas neuror {
pothujanangal
} ;
shoonyatha *
puthiya oopparettar (std:: siez _ t valuppam, koonst chaar * phayal, inttu line)
 (shoonyamaaya * p =:: oopparettar puthiyath (valuppam, STD:: nottoo))
 pii thirike nalkuka;
 puthiya pishak (phayal, line);
sthalam neekkam cheyyuka.
mukalil soochippichathupole, placement delete expression illa. oru cockways _ 2 expression upayogichu "eathenkilum" placement cockways _ 10 function vilikkaan kazhiyilla.
placement delete functionukale placement kokwos _ 1 expressionukalil ninnaan vilikkunnathu. prathyekichum, vasthuvinte nirmmaathaav oru apavaadam erinjaal avaye vilikkunnu. atharamoru saahacharyathil, prograaminu memory chorcha undaakillenn urappaakkunnathin, placement delete functionukal vilikkunnu. oru puthiya sthaananirnnaya padaprayogam aadyam sthaananirnayathe cocks _ 7 function ennu vilikkunnu, thudarnnu alokkettar functionil ninnu madangiya asamskritha sambharanathil vasthuvinte nirmmaathaavine vilikkunnu. kanstraktar oru exption eriyukayaanengil, puthiya expression nadappilaakkiya kodilekk exption veendum pracharippikkunnathin munbu aaa storeju neekkamcheyyendathu aavasyamaanu, athaanu playsment delete functionukalude uddeshyam.
playsment delete function ennu vilikkunna playsment puthiya expression vilicha playsment puthiya functionumaayi poruthappedunnu. udaaharanathinu, inipparayunna coode execute cheiyukayaanenkil, playsment delete function ennu vilikkunnathu coche _ 41 ayirikkum
a {} roopappeduthuka;
ghadana e {};
klaas tii {
pothujanangal
shoonyamaaya oopparettar puthiyath (std:: valuppam _ t, konstaatt a &) {
 STD:: cout "puthiya playsment ennu vilikkunnu."" STD:: endell;
shoonyamaaya oopparettar illaathaakkuka (shoonyamaaya *, sthiramaaya a &) {
 STD:: cout "playsment delete ennu vilikkunnu."" STD:: endell;
int maine (){
 eiii eiii;
 sramikkuka {
 t * p = puthiya (a) t;
 } catch (iii expi) {
 STD:: cout "exception catch cheythu."" STD:: endell;
 0 thirike nalkuka;
athukondaanu "pooyintar placement" delete functionukal staanderd sii + + library noow-ooppareshans ennu nirvachichirikkunnathu. pooyintar placement puthiya functionukal oru sambharanavum anuvadikkaathathinaal, objectinte kanstraktar oru apavaadam erinjaal sambharanam neekkamcheyyendathilla.
poruthappedunna placement delete function nilavilillengil, oru playsment kokwos _ 1 expressioninullil oru kanstraktar oru exption erinjaal delocation function vilikkilla. placement deletine pinthunaykkaattha chila (pazhaya) sii + + nadappaakkalukalum undu (exption-throying alokkettar functionukal pole, ithu staanderdais cheythappol sii + +-lake cherthathaanu). atharam rund saahacharyangalilum, oru ishtaanusritha alokkettar upayogikkumbol oru kanstraktar oru ozhivakkal memory chorchaykku kaaranamakum. (pazhaya sii + + nadappaakkalukalude kaaryatthil, "noonn-" playsment kokwos _ 1 eksprashanukalkkoppam oru memory chorchayum sambhavikkum.)
suraksha.
puthiya padaprayogangal sthaapikkunnathu suraksha chooshanangalkk irayaakunnu. 2011ll, kunduvum bertino puthiya playsmentil chila nettangal pradharshippichu. buffer overflo akramanangal, object overflo, selective stackgaard overriding, vertual pooyintar subterfuge, memory misalainment akramanangal ennivayaanu chila akramanangal. 2015ll, kandethalukalude adisthaanathil jisisi oru paachu puratthirakki.