what is available in C language but not in C++?

Answer Posted / preeti singh

C allows a void* pointer to be assigned to any pointer type
without a cast, whereas C++ does not.

void* ptr;
int *i = ptr;

int *j = malloc(sizeof(int) * 5);

this is valid in C but not in C++.
In C++ explicit cast needs to be applied as given below.

void* ptr;
int *i = (int *) ptr;

int *j = (int *) malloc(sizeof(int) * 5);

Is This Answer Correct ?    13 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the significance of an algorithm to C programming?

789


What are the benefits of c language?

860


What is the difference between specifying a constant variable like with constant keyword and #define it? i.e what is the difference between CONSTANT FLOAT A=1.25 and #define A 1.25

1697


Write a program to find factorial of a number using recursive function.

844


Why malloc is faster than calloc?

795


which of the following is not a character constant a) 'thank you' b) 'enter values of p, n ,r' c) '23.56E-o3' d) all of the above

1758


How do we open a binary file in Read/Write mode in C?

960


Is calloc better than malloc?

781


What is the c value paradox and how is it explained?

791


What is volatile variable how do you declare it?

757


Given a valid 24 hour format time find the combination of the value and write a program ,do not hard the value and if any other inputs provided should work with the logic implemented Input: 11:30 Output: 13:10 Input: 18:25 Output: 21:58

1302


What is the difference between malloc() and calloc()?

1038


What is an lvalue?

831


What are external variables in c?

772


How the c program is executed?

858