answersLogoWhite

0


Best Answer

A no converting type cast is a type cast where the underlying data type is intrinsically the same as the type being cast, thus no conversion is required. This will often occur when explicitly converting from one type definition to another when both are in fact the same definition.

For instance, type casting from an unsigned int to a size_t is a no converting type cast because the size_t data type is merely a type definition (typedef) for an unsigned integral. Thus type casting between any of the following would result in a no converting type cast:

unsigned

unsigned int

unsigned long

unsigned long int

size_type

size_t

Note that unsigned and long are both modifiers, not types. If you omit the type, int is assumed, thus the first four are fundamentally unsigned int.

Note also that a conversion and a type cast are not really the same thing, but they do similar jobs. A conversion is an implicit conversion between types while a type cast is an explicit conversion between types. In other words, they're both conversions, but not all conversions are type casts.

This is best demonstrated with some examples:

int i = 3;

In the above example, the literal constant 3 is implicitly int, thus this is an example of a no conversion type cast (same fundamental type).

long j = long (i);

The above example is also a no converting type cast because int and long are fundamentally the same type. Remember, long is a modifier, not a type in its own right, thus long int is implied, and a long int is fundamentally the same as an int.

unsigned int k = i;

The above example is an implicit conversion because the value of i (3) is assigned to a fundamentally different type to that of i.

unsigned int l = (unsigned int) i;

unsigned int m = static_cast<unsigned int> (i);

The above examples are explicit conversions (type casts). Both explicitly cast the integral 3 to an unsigned int.

Explicit conversion (type casting) between primitive types is usually unnecessary because the compiler knows how to convert between these types and it's generally not something the programmer need overly concern themselves with. However, it can sometimes be important to highlight the fact that a conversion is taking place. In these cases it is best to be explicit and the static_cast operator is the best way of making the cast stand out. Conversion to or from more complex objects should be handled by the object's themselves through class conversion operators that implement static_cast where appropriate, and dynamic_cast or reinterpret_cast when the conversion is more complex. Again, it can be important to highlight the fact a conversion is taking place so it's best to keep conversion operators to the absolute minimum and force consumers to be explicit with their conversions. You can also use const_cast to highlight the fact that the constness of a type is being converted.

User Avatar

Wiki User

9y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

A type conversion is where the compiler generates code to convert from one type to another. For instance, you might assign the value of a integer variable to a floating point variable, or vice versa. The compiler will do that for you. There is explicit type conversion, where you specify which type to convert to, and implicit type conversion, where it is implied by context, such as across an assignment or in a mixed expression.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

"Type conversion" means pretty much the same thing in any programming language, and it's difficult to explain unless you already know something about programming.

Basically, a computer program can represent the number "25" (for example) in several ways. Type conversion is a way of converting between those ways. C++ is "strongly typed", which means the compiler will usually give you an error if you try to use a variable of one type in a way that expects a different type. Some languages (for example, Perl) are not strongly typed, and you can get away with these kinds of shenanigans, but in C++ you'd usually have to do "type conversion" to avoid the error.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What do you mean by type conversion in c plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Where can you find quine mccluskey method written in C plus plus?

See related link. It's in C rather than C++, but conversion to C++ is fairly simple.


What does 61 F degrees mean in Celsius?

If you mean 61 angular degrees , they are already metric. If you mean 61 degrees Kelvin the conversion gives -212.15&deg;C (Centigrade or Celsius If you mean 61&deg; Fahrenheit the conversion gives 16.1&deg;C If you men R&eacute;aumur the conversion gives 76,25&deg;C


What is the name of the structure type in C plus plus?

The same as in C, struct.


User defined data type in c plus plus?

Use "typedef" : both in C and C++.


How do you apply if in char type in c plus plus?

char x = "C"; if(char == 'C') { } else { }


What is the mean c plus plus in machine code?

It is used to distinguish between the C or C++


Casting in c plus plus?

Yes, you can cast in C++, both statically and dynamically. Objects can also be cast provided the class designer implemented the appropriate conversion operators.


What are the features of C plus plus that surpass C?

Object-oriented programming and stricter type-safety.


How unary minus can be overload in c plus plus?

type operator- ();


What does tbuffer mean in c plus plus?

There is no such keyword or data type known as tbuffer in C++. It's most likely an user-defined identifier, possibly a text buffer. But without knowing its actual type or its context it's impossible to say what it means.


In C plus plus Interface is also known as?

I guess you mean Java, there is no interface in C++.


What is a primitive type variable in c plus plus?

same the types used in C. that is int...char...float...