Thread: How to resolve this error in c++?

  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    18

    Talking How to resolve this error in c++?

    this code in c++
    #include <iostream>
    using namespace std;
    int main()
    { return 0; }
    struct X;
    struct Y;
    struct Y
    { X ox; };
    struct X
    { Y oy; };
    gives error as:"field `ox' has incomplete type"
    how to resolve it without using pointer

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Using a pointer member is probably the correct approach. If not, you might use a reference member.
    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
    Oct 2008
    Posts
    1,262
    Use code tags, first of all... Other than that, the problem can't be resolved without pointers. See, if "A" contains "B" but "B" contains "A"... That's kind of impossible unless A == B.

  4. #4
    Registered User
    Join Date
    May 2010
    Posts
    18
    yes reference will definitely work ,
    but I don’t understand code tag ,EVOEx,will u please elaborate this.

  5. #5
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    Quote Originally Posted by hr1212s View Post
    yes reference will definitely work ,
    but I don’t understand code tag ,EVOEx,will u please elaborate this.
    Before code, add the text "[ code ]" (without spaces). After the code at "[ /code ]" (without spaces). If you do that code should be indented. See the difference:

    #include <iostream>
    int main()
    {
    for(int i = 0; i < 100; ++i)
    std::cout << i << std::endl;
    }

    (No code tags)

    Code:
    #include <iostream>
    int main()
    {
      for(int i = 0; i < 100; ++i)
        std::cout << i << std::endl;
    }
    (with code tags)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to resolve conflicts in SVN?
    By jutirain in forum Tech Board
    Replies: 0
    Last Post: 01-19-2008, 10:51 PM
  2. Resolve Arithmetic operations
    By louis_mine in forum C Programming
    Replies: 3
    Last Post: 11-13-2006, 09:14 PM
  3. Cannot resolve overloaded function
    By Mithoric in forum C++ Programming
    Replies: 10
    Last Post: 11-29-2003, 03:40 AM
  4. How to resolve linking errors?
    By m712 in forum C++ Programming
    Replies: 3
    Last Post: 11-03-2002, 10:17 PM
  5. Resolve error in Windows Macro?
    By Adock in forum C Programming
    Replies: 2
    Last Post: 03-19-2002, 08:41 PM