Thread: Can you use a structure in the declaration of itself?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    19
    Ok, so reading from above, sayine node *next, doesnt create a node/structure of pointers, just a pointer. So the syntax is for clarity only, and the pointer is part of the structure.

    So why not just say int *ptr?

    Thanks very much and so FAST?

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >So why not just say int *ptr?
    Because a pointer to foo isn't the same as a pointer to int. The two have different types, and the type of anything is important information. If the type of the pointer and the type of the pointed to object don't match, the chances of your program crashing are pretty good.
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Quantum Random Bit Generator
    By shawnt in forum C++ Programming
    Replies: 62
    Last Post: 06-18-2008, 10:17 AM
  2. failure to import external C libraries in C++ project
    By nocturna_gr in forum C++ Programming
    Replies: 3
    Last Post: 12-02-2007, 03:49 PM
  3. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  4. Errors with including winsock 2 lib
    By gamingdl'er in forum C++ Programming
    Replies: 3
    Last Post: 12-05-2005, 08:13 PM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM