Re:Arrays of Arrays (2009)
by kqr on Sunday December 20, 2020 @02:18AM
(#25484566)
This reasoning seems to me similar to how declaring a pointer in e.g. C works: many beginners write
And think that this constructs two pointers-to-integer. In fact, it constructs one pointer and one plain integer. A better (equivalent) way to write it is
You're not declaring variables of type
You're saying that b is an int and
Is an int, where the asterisk means "the dereferenced a"!
[ Parent
| on HN ]
Re:Arrays of Arrays (2009)
by pwdisswordfish4 on Sunday December 20, 2020 @08:20AM
(#25486043)
Beginners and also C++ programmers, expert and beginner alike. Even though it’s just as misleading in C++. This:
int a = 0;
int& x = a, y = a;
declares x to be a reference, but y an independent variable. Similarly, a template parametrised by a variadic pack of function pointers is declared thus: template <void (*...x)(void)>
It’s a good thing I don’t work in C++ too often, because my forehead would have probably sustained noticeable injury from all the facepalming each time I see ‘int& x’ instead of ‘int &x’ and ‘typename... T’ instead of ‘typename ...T’.