| 1888 Articles Home | Computer Articles | Website Promotion Articles | Computer RSS | ![]() |
||
Typecasting and its importance in C++ |
||||
|
Type Casting causes the program to treat a variable of one type as though it contains data of another type. Read brief tutorial on typecasting in c++. |
||||||||||||
| Author: James Edward |
|
|||||||||||
Casting means you change the representation of a variable by changing its type to a different one. In order to type-cast a simple object to another you use the traditional type casting operator. For example, to cast a floating point number of type 'double' to an integer of type 'int'.
Type Casting causes the program to treat a variable of one type as though it contains data of another type. Normally, this is used with a collection of pointers (addresses) to specify how to interpret the data. When casting is not used with object pointers, it normally means to simply copy the data between incompatible types without converting the data or flagging an error. The figure lists some examples for type casting of operators.
Format: Type name (Expression);
Let us see the concept of type casting in C++ with a small example:
#include
void main()
{
int a;
float b,c;
cout>a;
cout>b;
c = float(a)+b;
cout
About Author
Expert in Computer Programming Languages and Web Development and Designing Technologies. http://www.studiesinn.com
Article Source:
http://www.1888articles.com
Other Related Articles Creative Writing Techniques by Tracey Tressa Bad credit loans: Get finance despite impaired credit score by Halliwell Typecasting and its importance in C++ by James Edward 5 Sure Ways To Cure "Internet Marketing Overload" by Diane C Hughes Incoming Emails go to Deleted Items Folder in Outlook by Mr John Peter |

