• mo_ztt ✅
    link
    English
    151 year ago

    For each object of such a composed type, there was already a way to mention the underlying object: index the array, call the function, use the indirection operator on the pointer. Analogical reasoning led to a declaration syntax for names mirroring that of the expression syntax in which the names typically appear. Thus,

    int i, *pi, **ppi;

    declare an integer, a pointer to an integer, a pointer to a pointer to an integer. The syntax of these declarations reflects the observation that i, *pi, and **ppi all yield an int type when used in an expression. Similarly,

    int f(), *f(), (*f)();

    declare a function returning an integer, a function returning a pointer to an integer, a pointer to a function returning an integer;

    After almost 30 years, I think I just understood function pointer declaration syntax for the first time.