Thread: something not a structure or union

  1. #1
    Registered User
    Join Date
    Dec 2012
    Posts
    61

    something not a structure or union

    Hi! I'm getting some error on my function below:

    Code:
    Tree** getSibling(Tree** root, char* token) {
        return !strcmp(token, root -> token) ? &(root -> child) : getSibling(&(root -> sibling), token);
    }
    The error message is:

    Code:
    error: request for member ‘token’ in something not a structure or union
    error: request for member ‘child’ in something not a structure or union
    error: request for member ‘sibling’ in something not a structure or union
    How can I fix this? Thanks.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    root is a Tree**, therefore *root is a Tree*. A pointer to Tree does not have a member named token. Perhaps you meant to write (*root)->token
    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
    Dec 2012
    Posts
    61
    Thanks @laserlight. Problem solved

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Structure Vs Union
    By mgnidhi_3july in forum C Programming
    Replies: 17
    Last Post: 06-16-2010, 09:45 PM
  2. union inside structure
    By vijay s in forum C Programming
    Replies: 1
    Last Post: 12-03-2009, 07:21 AM
  3. structure and union
    By BEN10 in forum C Programming
    Replies: 10
    Last Post: 06-24-2009, 11:30 PM
  4. Structure / Union Error
    By JimpsEd in forum C Programming
    Replies: 2
    Last Post: 11-11-2006, 01:03 PM
  5. Structure containing a union of more structures!
    By Bajanine in forum Windows Programming
    Replies: 2
    Last Post: 03-08-2003, 11:53 AM