Find jobs | Company-wise jobs
Jobseekers | Employer login
About us Sitemap of www.CareerRide.com Sitemap FAQ related with www.CareerRide.com FAQ Click here to Contact us Contact
       
Submit Resume Free ! | Access Resume Free !
Home Interview Q&A Tutorials .NET Java Soft skills CV GD Work from home IT practice test MBA practice test FAQs in PDF Books Jobs FAQs
Interview questions                  
C++ interview
C interview
C test!
C++ test!
Data structure test!
C++ access control
C++ COM
C++ constructors destructors
C++ containers
C++ DCOM
C++ derived class
C++ error handling
C++ exception handling
C++ friend members
C++ inheritance
C++ inline function
C++ memory leaks
C++ namespaces
C++ new and delete
C++ operator overloading
C++ pointers
C++ references
C++ static data
C++ syntax
C++ template
C++ type checking
C++ virtual functions
C++ pure virtual functions
C++ as an object-oriented
More concept of C++
C++ data types
C++ control constructs
C++ collections
C++ functions
C++ arrays
C++ C-string
C++ classes and structure
C++ Friend functions & classes
C++ polymorphism
C++ multiple inheritance
C++ function template
C++ class templates
C++ standard stream class
ATL server
Data structure in C++
 

What is Typecasting? Explain with examples.

<<Previous  Next>>

C++  - What is Typecasting? Explain with examples - Nov 18, 2008 at 15:30 pm by Anuja Changede

What is Typecasting? Explain with examples.  

Typecasting: C++ is very strict about type compatibility. Different variable types must be cast when their values are assigned to each other. Type cast operator is used for explicit type conversion of variables. A type name behaves as if it is a function for converting values to a designated type.

E.g. average = sum/float(i);
The variable ‘i’ is converted to float and used to calculate the average.

C++  - What is Typecasting? - Feb 23, 2009 at 23:05 pm

Explain typecasting.

Answer - Typecasting enables data type conversion. C++ supports Implicit conversions and Explicit conversion. Implicit conversions automatically performed when a value is copied to a compatible type. If there is an operation between an int and a float, the int is promoted to float before performing operation.

You can cast types explicitly as follows.
int i, j, k;
k = i * long(j);

Also read

What is the difference between dynamic and static casting?

1) for implicit casts that the compiler would make automatically anyway (bool to int)
2) as a mandatory forced cast (float to int)....................

What is Typecasting? Explain with examples.

Typecasting: C++ is very strict about type compatibility. Different variable types must be cast when their values are assigned to each other. Type cast operator is used for explicit type conversion of variables.......................

<<Previous  Next>> 

 

 
Want to be hunted by potential employers? Just submit your key skills!

Popular FAQs

.NET .Net Architecture ADO.NET Java Oracle C#.NET
VB.NET DOT.NET AJAX ASP.NET NET Framework OOPS in .NET
C++ Sql Server Data warehousing EJB MySQL Linux
PHP UML Networking Testing XML  
 
Copyright © 2008 - 2010 CareerRide.com. All rights reserved.