Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This also makes a big difference once we start talking about pointers to arrays.

    int a[] = {1, 2, 3}
    int (*p1)[3] = &a; // ok
    int (*p2)[3] = &a[0]; // not ok
    int *p3 = &a; // not ok
(It should be noted that these will compile with warnings in C due to implicit conversions via void*, but you're still risking UB if you actually use the resulting value. They are all errors in C++ because it doesn't have implicit conversion from void*.)


Nothing wrong with your third line. Did you mean something else?


I forgot the &; comment updated now, and I added another example.


Got it, thanks!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: