Thread: ADT delcaration question

  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    26

    Question ADT delcaration question

    Hi all:

    I have written the following block of code:

    Code:
    typedef struct VIEW_TAG
    {
    	char name[16];
    	VIEW_MEMBER *ptrViewMembers;
    	VIEW_MEMBER *ptrLastAddedMember;
    	struct VIEW_TAG *ptrNextView;
    }VIEW;
    It complied OK, but my question is that is it correct to create a member of the a structure itself in the very same structure? Does not sound logical?

    My guess is that during compiling, does not know what a "VIEW_TAG" and will give me an error, but it does not.

    Can anyone help?

    Cheers

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    You have a pointer to struct VIEW_TAG as a member in struct VIEW_TAG, and that is fine.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Sep 2008
    Posts
    26
    Thank you laserlight.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with linked list ADT and incomplete structure
    By prawntoast in forum C Programming
    Replies: 1
    Last Post: 04-30-2005, 01:29 AM
  2. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  3. ADT question
    By campermama in forum C++ Programming
    Replies: 3
    Last Post: 06-08-2004, 07:58 AM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM