4 ms·
So what about smart pointers? Is it not inconsistent that smart pointers are a type but raw pointers are not?
by jayd16 2y ago
So what about smart pointers? Is it not inconsistent that smart pointers are a type but raw pointers are not?
- jstimpfle 2y agoRaw pointers "are" a type too. It's just that there isn't really syntax to describe the type, at least in the original declaration syntax. Note that structs and typedefs that you define are proper type names, you can switch out "int" for them. You can easily "typedef int *intPtr;" and then merrily go "intPtr myptr". (I think cast type-specs might be a bit of an exception here were the rule breaks a bit -- because they don't "use" a name in the cast "expression". I don't intimately understand how those work. The whole thing is an idea that was stretched to the limits, especially with C++ where consistency has pretty much been given up).