0

Possible Duplicate:
C++ typedef interpretation of const pointers

I just learned that typedef does weird things with pointers

Here's an example:

typedef float* fptr;
const fptr f; // This is float * const f instead of const float * (like I wanted)

Why does it do that?

Community
  • 1
  • 1
purepureluck
  • 1,271
  • 2
  • 14
  • 16
  • How is this "weird"? It does exactly what it says on the tin. It's true that C++ contains "weird stuff", but this is certainly not an example. – Kerrek SB Jan 31 '12 at 19:34
  • Read what you wrote. `fptr` is what? It is a pointer to float. What do you get when you make that constant? A constant pointer to float. – Šimon Tóth Jan 31 '12 at 19:35

1 Answers1

3

Seems like already answered in :

C++ typedef interpretation of const pointers

See also Is it a good idea to typedef pointers? for more of a discussion on typedef and pointers.

Community
  • 1
  • 1
Sid
  • 7,511
  • 2
  • 28
  • 41