-1

What does those notations refer to ? What am i declaring ? I have a hard problem identifying what is being declared

1 - double (*b)[n];  
2 - double (*c[n])();  
3 - double (*d())[n];  

And i can't even think in understanding this one

double (*foo(double (*) (double, double[]),double)) (double, ...);

Overall, if there is any logic or step-by-step i can use for almost all ( or preferably al ) cases, would be really great to know.

user1843665
  • 353
  • 2
  • 3
  • 7
  • 5
    Take a look at the [spiral rule](http://c-faq.com/decl/spiral.anderson.html). – chris Feb 08 '13 at 03:32
  • 3
    For many cases there is the nifty gadget at [cdecl.org](http://cdecl.org/). – Jonathon Reinhart Feb 08 '13 at 03:33
  • Thanks, i did search a lot but didn't know the keywords for finding material about such topic – user1843665 Feb 08 '13 at 03:35
  • Hey, can't thank enough for the spiral rule site, i just figured out all examples. cdecl gadget was rly nice to save some time too,i'm saving it. Realy impressive how the community here is quick and proficient – user1843665 Feb 08 '13 at 03:41
  • but in all honesty... why? it's so easy to confuse, and not everyone is a c++ veteran. if you work in a team, chances are that using something like this is a recipe for disaster. – thang Feb 08 '13 at 03:50
  • 1
    True, type aliases and some sort of `identity` template would make these much more readable. – chris Feb 08 '13 at 03:51

1 Answers1

3
double (*b)[n];  

This is a pointer named b that points to an array of doubles that has length n.

double (*c[n])();  

This is an array named c of n pointers to functions that take in unspecified arguments (in C) or no arguments (in C++) and return doubles.

double (*d())[n];  

This is a function named d that returns a pointer to an array of n doubles.

Hope this helps!

templatetypedef
  • 362,284
  • 104
  • 897
  • 1,065