cplusplus.com cplusplus.com
cplusplus.com   C++ : Forums : Windows Programming : Question about typdef/struct
  Search:
- -
C++
Information
Documentation
Reference
Articles
Sourcecode
Forums
Forums
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Articles
Lounge
Jobs

-

question  Question about typdef/struct

Zhuge (102)
How is typedef struct Name { /* ... */ } Name; special?
To me it seems like writing something like typedef Type Type; which seems pointless.
|
Duoas (1515)
You are correct.

The typical reason to do that is to handle self-referential cases:
1
2
3
4
5
6
7
8
typedef struct node_tag
  {
  int x, y;
  node_tag* next;
  }
node_t;

node_t* head_point;  // head node of a linked list 
|

This topic is archived - New replies not allowed.
Home page | Privacy policy
© cplusplus.com, 2000-2008 - All rights reserved - v2.2
Spotted an error? contact us