Posts

Showing posts from January, 2013

Void pointers: Difference between c and c++

I'm trying to understand the differences between C and C++ with regards to void pointers. the following compiles in C but not C++ :
int* p = malloc(sizeof(int));
However, here:
void foo(void* vptr){}int main(){int* p =(int*) malloc(sizeof(int)); foo(p);return0;} Both C++ and C compile it with no complain. Why?