[Cs3] Casting Question from Lab

Mikhail Nesterenko mikhail at cs.kent.edu
Wed Jul 16 12:48:05 EDT 2014


> In your fill example, why does C-style casting work with the conditional
> assignment for userBox, but C++ style casting causes errors?

Apparently function style (that is "old" C++ style) casting does not work with
pointers directly. This, however, works:

   typedef Fill* FillPtr;
   auto test = FillPtr(new Filled('a'));

In any event, C-style and old C++ casting syntax is considered unsafe.
Use static_cast instead.

Thanks,
-- 
Mikhail


More information about the cs3 mailing list