I think the issue is that programmers want a type "pointer to int", for example, but C doesn't directly provide that type. It has a type, int, with a modifier (asterisk) that can be applied
to a declarator to make it a pointer to that type.
One way to create a pointer type in C would be to declare it using typedef:
typedef int * int_p;
then one can write:
int_p p, q, r;
and declare three pointers to int with perfect clarity, whereas using the C++ style, we'd get:
int* p, *q, *r;
which is very confusing, or,
int* p;
int* q;
int* r;
which is very verbose. I honestly don't know how C++ programmers typically handle this situation.
I have seen some code that strikes a middle ground:
int * p;
which is a little more clear, but doesn't address the multiple declarator situation.
So why don't C++ programmers use typedef? I don't know, other than I understand Stroustrup doesn't like it (not without reason).
(Edited for formatting and minor clarity corrections.)
One way to create a pointer type in C would be to declare it using typedef:
then one can write: and declare three pointers to int with perfect clarity, whereas using the C++ style, we'd get: which is very confusing, or, which is very verbose. I honestly don't know how C++ programmers typically handle this situation.I have seen some code that strikes a middle ground:
which is a little more clear, but doesn't address the multiple declarator situation.So why don't C++ programmers use typedef? I don't know, other than I understand Stroustrup doesn't like it (not without reason).
(Edited for formatting and minor clarity corrections.)