4 ms·
I have been writing C and C++ for a little more than 10 years now and this is the first I have heard "declarations mirror use". I understood that was the case,
by sqeaky 10y ago
I have been writing C and C++ for a little more than 10 years now and this is the first I have heard "declarations mirror use". I understood that was the case, but why is the phrase important.
To me understanding the actual types involved is more important than getting the declaration to look some specific way. (So I always jammed the star next to type and did whatever else I though would most ease expressing types)
I am also the kind of developer who who have declared it as:
std::array<std::string, X> arr;
or
std::vector<std::string> arr;
depending on if X was known at compile time. Because I want to give the compiler as many chances to call out my mistakes as possible.