🟣 C++ Language • Hindi Tutorial Lesson 19/20

Type Conversion in c++

Introduction to 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


chi 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 से बताया जा रहा है।


Prev Tutorial
friend functions in c++