Introduction to C++ type conversion


Introduction to C++ type conversion

C++ type conversion
C++ type conversion

Type conversion एक ऐसी process होती है जिसमें एक तरह के data type की value/variable को दूसरे तरह के data type के variable को assign किया जाता है। ऐसा सिर्फ किसी एक particular operation के लिए किया जाता है, हर बार ऐसा नहीं होता है। 

उदाहरण के लिए आप program में एक int type का और दूसरा float type का variable create करते है। Integer type के variable को आपने initialize नहीं किया है। Float type के variable में आपने एक floating point value डाली है। जैसा की नीचे दिए गए उदाहरण में show किया गया है।       

int num;
float numf = 10.5 
   
यदि इस situation में आप float type का variable int type के variable को assign करते है तो type conversion occur होगा। Float type के variable की value integer में convert हो जायेगी और integer variable को assign कर दी जायेगी। 

इस operation के बाद integer variable में एक whole number होगा। ऊपर दिए गए उदाहरण में integer variable में 10 value होगी।  

Type conversion को type casting भी कहा जाता है। Type conversion implicit और explicit 2 प्रकार का होता है। इनके बारे में आगे के sections में detail से बताया जा रहा है।   

Share this

Related Posts

Previous
Next Post »

please comment your choice game ...