在C++14标准(C++98/11也一样)中,在Annex C Compatibility里有这么一条:
Change: Converting void* to a pointer-to-object type requires casting
1 | char a[10]; |
ISO C will accept this usage of pointer to void being assigned to a pointer to object type. C ++ will not.
但是为什么operator new()
会返回void*
且不用显式转换为T*
就能赋值给T*
呢?