How to resolve this error in c++?

This is a discussion on How to resolve this error in c++? within the C++ Programming forums, part of the General Programming Boards category; this code in c++ #include <iostream> using namespace std; int main() { return 0; } struct X; struct Y; struct ...

  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
    21,311
    Using a pointer member is probably the correct approach. If not, you might use a reference member.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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, 09:51 PM
  2. Resolve Arithmetic operations
    By louis_mine in forum C Programming
    Replies: 3
    Last Post: 11-13-2006, 08:14 PM
  3. Cannot resolve overloaded function
    By Mithoric in forum C++ Programming
    Replies: 10
    Last Post: 11-29-2003, 02:40 AM
  4. How to resolve linking errors?
    By m712 in forum C++ Programming
    Replies: 3
    Last Post: 11-03-2002, 09:17 PM
  5. Resolve error in Windows Macro?
    By Adock in forum C Programming
    Replies: 2
    Last Post: 03-19-2002, 07:41 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21