C allows a void* pointer to be assigned to any pointer type without a cast, whereas C++ does not; this idiom appears often in C code using malloc memory allocation. For example, the following is valid in C but not C++:
In order to make the code compile in both C and C++, one must use an explicit cast:
- return statement in C/C++ with Examples
- size of char datatype and char array in C
- Logical Not ! operator in C with Examples
- How to implement our own Vector Class in C++?
- Web Programming in C++
- C++ Program to print an Array using Recursion
- Storage Classes in C++ with Examples
- fill_n() function in C++ STL with examples
- fill() function in C++ STL with examples
- How to erase an element from a vector using erase() and reverse_iterator?
- iomanip setbase() function in C++ with Examples
- iomanip setpricision() function in C++ with Examples
- iomanip setiosflags() function in C++ with Examples
- iomanip setfill() function in C++ with Examples