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

Create a simple code fragment that will swap the values of two variables num1 and num2.

814


How do I round numbers?

601


number of times a digit is present in a number

1544


largest Of three Number using without if condition?

1009


Which is better oop or procedural?

634






Why is c called c not d or e?

615


What is the purpose of the following code? Is there any problem with the code? void send(int count, short *to, short *from) { /* count > 0 assumed */ register n = (count + 7) / 8; switch (count % 8) { case 0: do { *to = *from++; case 7: *to = *from++; case 6: *to = *from++; case 5: *to = *from++; case 4: *to = *from++; case 3: *to = *from++; case 2: *to = *from++; case 1: *to = *from++; } while (--n > 0); } }

1959


Explain how can type-insensitive macros be created?

572


What is header file in c?

605


how is the examination pattern?

1598


The difference between printf and fprintf is ?

720


Study the following C program :call_me (myvar)int myvar;{ myvar +- 5; }main(){int myvar;myvar = 3;call_me(myvar);printf("%d ",myvar);What will be printed a) 3 b) 5 c) 8 d) symbol

667


what is stack , heap ,code segment,and data segment

2224


Who developed c language and when?

586


what is the basis for selection of arrays or pointers as data structure in a program

3789