Type conversion | Automatic and Typecasting – Object Oriented Programming (OOP)

Download our Android App from Google Play Store and start reading Reference Notes Offline.

type conversionType conversion
Object Oriented Programming(OOP)
Third Semester | Second year
BSc.CSIT | Tribhuvan University (TU)

Type conversion
In C++ object oriented programming language, smaller memory data type variable can be converted to large data type by the compiler. It is required to make the language robust. When a variable of int type is multiplied by a variable of float type then the output is saved inside the computer system memory as double data type. Thus C++ permits mixed expressions. Type conversion can be done by following two ways;

when an expression consists of more than one type of data elements in an expression, the C++ compiler converts the smaller data type element in larger data type element. This process is known as implicit or automatic conversion.

This statement allows the programmer to convert one data type into another data type by writing the following syntax:
aCharVar = static_cast(an IntVar);

Here in the above syntax char variable will be converted into int Variable after execution of the syntax in the C++ program.

(Visited 638 times, 1 visits today)

Posted By : Digvijay | Comment RSS | Category : Third Semester
Tag :

Post a Comment

Your email is never published nor shared. Required fields are marked *


Wordpress DMCA
Community | Toolbar | Android App | Founder/Developer : Hari Prasad Chaudhary | CSIT Portal Manager : Digvijay Chaudhary