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
What are identifiers c?
Explain what is the best way to comment out a section of code that contains comments?
What is class and object in c?
Can a function be forced to be inline? Also, give a comparison between inline function and the C macro?
Is r written in c?
Why functions are used in c?
Which is best book for data structures in c?
How can I implement sets or arrays of bits?
The statement, int(*x[]) () what does in indicate?
What is the total generic pointer type?
what is a function method?give example?
What is 'bus error'?
Explain that why C is procedural?
Which is better pointer or array?
What should malloc(0) do?