Easy Error I can't seem to find

This is a discussion on Easy Error I can't seem to find within the C++ Programming forums, part of the General Programming Boards category; Basically i have an error that i can normally easily fix but i can't this time. Its really annoying i've ...

  1. #1
    Registered User
    Join Date
    Mar 2007
    Posts
    109

    Easy Error I can't seem to find

    Basically i have an error that i can normally easily fix but i can't this time. Its really annoying i've spent so much time trying to figure this easy error out and can't locate it because there are no open brackets they are all closed. maybe someone else can see, sorry for having to post the whole code btw. ?I've narrowed it down to this part

    Code:
        // ********** operator >=() tests **********//
        cout << "**** operator >=() tets ****" << endl;
        //test positive
        cout << "Expecting OK:" << endl;
        a.Set("123456789");
        b.Set("123456789");
        if (a >= b)
        {
            cout << "OK" << endl;
        }
        else
        {
            cout << "123456789 >= 123456789: ERROR" << endl;
        }
        cout << "Expecting OK:" << endl;
        a.Set("123456789");
        b.Set("12345678");
        if (a >= b)
        {
            cout << "OK" << endl;
        }
        else
        {
            cout << "123456789 >= 12345678: ERROR" << endl;
        //test negative
        cout << "Expecting OK:" << endl;
        a.Set("-987654321");
        b.Set("-987654321");
        if (a >= b)
        {
            cout << "OK" << endl;
        }
        else
        {
            cout << "-987654321 >= -987654321: ERROR" << endl;
        }
        cout << "Expecting OK:" << endl;
        a.Set("-98765432");
        b.Set("-987654321");
        if (a >= b)
        {
            cout << "OK" << endl;
        }
        else
        {
            cout << "-98765432 >= -987654321: ERROR" << endl;
        }
        //********* End operator >=() tests *********
    return 0;
    }
    this is the error

    Code:
    main.cpp: In function ‘int main()’:
    main.cpp:382: error: expected `}' at end of input
    make: *** [bigint] Error 1
    Last edited by DarkDot; 05-02-2007 at 06:18 PM.

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Here I highlighted the matching pair:
    Quote Originally Posted by DarkDot View Post
    Code:
        // ********** operator >=() tests **********//
        cout << "**** operator >=() tets ****" << endl;
        //test positive
        cout << "Expecting OK:" << endl;
        a.Set("123456789");
        b.Set("123456789");
        if (a >= b)
        {
            cout << "OK" << endl;
        }
        else
        {
            cout << "123456789 >= 123456789: ERROR" << endl;
        }
        cout << "Expecting OK:" << endl;
        a.Set("123456789");
        b.Set("12345678");
        if (a >= b)
        {
            cout << "OK" << endl;
        }
        else
        {
            cout << "123456789 >= 12345678: ERROR" << endl;
        //test negative
        cout << "Expecting OK:" << endl;
        a.Set("-987654321");
        b.Set("-987654321");
        if (a >= b)
        {
            cout << "OK" << endl;
        }
        else
        {
            cout << "-987654321 >= -987654321: ERROR" << endl;
        }
        cout << "Expecting OK:" << endl;
        a.Set("-98765432");
        b.Set("-987654321");
        if (a >= b)
        {
            cout << "OK" << endl;
        }
        else
        {
            cout << "-98765432 >= -987654321: ERROR" << endl;
        }
        //********* End operator >=() tests *********
    return 0;
    }
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,239
    Code:
    else
        {
            cout << "123456789 >= 12345678: ERROR" << endl;
        } /* Is it here? */
        //test negative
        cout << "Expecting OK:" << endl;
        a.Set("-987654321");
        b.Set("-987654321");
        if (a >= b)
    EDIT: Doh! So close!

    Whenever you type a left brace, your fingers should have an irresistable urge to type the corresponding right brace. Write an empty block first, then fill it in. The other way to get your braces screwed up is sloppy copy or cut and paste. If your indentation is always clean, then you should be able to see that you've highlighted an entire valid region for the copy or cut.
    Last edited by brewbuck; 05-02-2007 at 06:45 PM.

  4. #4
    Registered User
    Join Date
    Mar 2007
    Posts
    109
    ok thanks but now that i fixed that the error i now have is
    Code:
    /tmp/cc4e8nE4.o: In function `main':
    main.cpp:(.text+0x1e56): undefined reference to `operator>=(BigInt const&, BigInt const&)'
    main.cpp:(.text+0x2017): undefined reference to `operator>=(BigInt const&, BigInt const&)'
    main.cpp:(.text+0x21d8): undefined reference to `operator>=(BigInt const&, BigInt const&)'
    main.cpp:(.text+0x2399): undefined reference to `operator>=(BigInt const&, BigInt const&)'
    collect2: ld returned 1 exit status
    make: *** [bigint] Error 1

  5. #5
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,239
    Quote Originally Posted by DarkDot View Post
    ok thanks but now that i fixed that the error i now have is
    Code:
    /tmp/cc4e8nE4.o: In function `main':
    main.cpp:(.text+0x1e56): undefined reference to `operator>=(BigInt const&, BigInt const&)'
    main.cpp:(.text+0x2017): undefined reference to `operator>=(BigInt const&, BigInt const&)'
    main.cpp:(.text+0x21d8): undefined reference to `operator>=(BigInt const&, BigInt const&)'
    main.cpp:(.text+0x2399): undefined reference to `operator>=(BigInt const&, BigInt const&)'
    collect2: ld returned 1 exit status
    make: *** [bigint] Error 1
    That means you never wrote operator>=(BigInt const&, BigInt const&). Or if you did, you aren't linking with the object it resides in.

  6. #6
    Registered User
    Join Date
    Mar 2007
    Posts
    109
    nevermind i was missing & in my implentation how stupid. thanks for all the help guys.
    Last edited by DarkDot; 05-02-2007 at 07:00 PM.

  7. #7
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    The one in the header passes by reference, the implemented one passes the entire BigInt by value. Perhaps those ought to match up? (ie, "const BigInt &a")

    (In other words: "That means you never wrote operator>=(BigInt const&, BigInt const&).")
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem building Quake source
    By Silvercord in forum Game Programming
    Replies: 16
    Last Post: 07-11-2010, 09:13 AM
  2. please help!...find and replace
    By amy589 in forum C++ Programming
    Replies: 26
    Last Post: 10-13-2006, 06:42 PM
  3. Can't find DirectX!!!
    By Queatrix in forum C++ Programming
    Replies: 2
    Last Post: 07-24-2006, 07:50 PM
  4. Replies: 3
    Last Post: 06-09-2006, 09:53 AM
  5. Q: Recursion to find all paths of a maze
    By reti in forum C Programming
    Replies: 7
    Last Post: 11-26-2002, 08:28 AM

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