Thread: Confusing Errors

  1. #1
    Registered User thePope's Avatar
    Join Date
    Mar 2003

    Unhappy Confusing Errors

    Hi I keep getting these errors (using g++ on UNIX)... In member function `void
    vehicle_array::remove_reg(vehicle_reg&)': error: no match for `vehicle_reg& == vehicle_reg&'
    operator error: name lookup of `i' changed for new ISO `for'
    scoping error: using obsolete binding at `i'

    Here's the snipet of code it is referring to:

    void vehicle_array::remove_reg(vehicle_reg& tmp){
    bool ctrl = false;
    for(int i = 0; i < used; i++){ //line 71
      if(veh_arr[i] == tmp){       //line 72
        ctrl = true;
      for(i ; i < used; i++){      //line 79
        veh_arr[i] = veh_arr[i + 1];
    Our instructor told us that the == operator was already overloaded for classes. Is this true? It seems to not be working in this case. I also understand this code is sorta messy, sorry. Any help would be appreciated though.
    Last edited by thePope; 10-14-2003 at 06:44 PM.
    My Computer: Pentium 266 MHz, 64MB Ram, 4Gb Hd

  2. #2
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    operator== (equality comparison) is not automatically overloaded for classes. Perhaps your teacher said that operator= (assignment) was automatically overloaded for classes? You will have to write operator== yourself.

  3. #3
    Senior Member joshdick's Avatar
    Join Date
    Nov 2002
    Phildelphia, PA
    As for the other error,
    for(int i=0; i<5; ++i)
    cout << i;  /* illegal.  the variable i went out of scope at the end of the for loop */
    If you want to use i after that for loop, then declare it outside of the for loop.

    "The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

    "If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Multiple syntax errors
    By Devolution in forum C Programming
    Replies: 1
    Last Post: 03-25-2009, 10:37 PM
  2. global namespace errors
    By stubaan in forum C++ Programming
    Replies: 9
    Last Post: 04-02-2008, 03:11 PM
  3. errors using my parser- MSVC++ 6, bhtypes.h
    By AeroHammer in forum C++ Programming
    Replies: 6
    Last Post: 01-25-2005, 07:11 PM
  4. opengl Nehe tutorial errors when compiling
    By gell10 in forum Game Programming
    Replies: 4
    Last Post: 07-14-2003, 08:09 PM
  5. errors in my class....
    By o0obruceleeo0o in forum C++ Programming
    Replies: 9
    Last Post: 04-14-2003, 03:22 AM