Re: [Dev-C++] problem with static casting (C++)
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: w.y. <yok...@ve...> - 2003-08-14 00:32:54
|
Zheo wrote: > > ptr1 = (A*) std::malloc( sizeof (*ptr1) ); You don't need std:: for malloc. Also you should use sizeof(A) instead. ptr1 = (A*) malloc( sizeof (A) ); > > ptr1 = static_cast<A*> std::malloc( sizeof (*ptr1) ); > You are missing () around the thing to be casted. ptr1 = static_cast<A*> ( malloc(sizeof(A)) ); Your other example here has them: > int* p = static_cast<int*>(malloc(100)) ; // new allocation used as ints |