Quantcast
Channel: User Peter - Reinstate Monica - Stack Overflow
Viewing all articles
Browse latest Browse all 239

Comment by Peter - Reinstate Monica on Why do C and C++ support memberwise assignment of arrays within structs, but not generally?

$
0
0
The compiler has complete information about an array (including its size, the number of elements and the size of each element) in exactly the same way it has complete information about a given struct. It obviously can exactly "tell the difference between int a[10] and int b[20]", Georg provided proof for that. (The array information is, of course, frequently lost when arrays are passed to functions which "adjusts" the type to a pointer. But that's a different matter and is a bit comparable to passing a pointer to a struct that has only been forward-declared.)

Viewing all articles
Browse latest Browse all 239

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>