Thread: I am trying to write a code to search a class

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    38

    Exclamation I am trying to write a code to search a class

    not sure what i am doing wrong can someone please explain

    program compiles fine, when ran it crashes.

    this is the code i am using

    Code:
     int tempID;
                         cout << "Please enter the Student ID number\n";
                         cin >> tempID;
                         for (int i=0; i < total; i++)
                              if (tempID == student[i].getID())
                                  cout << student[i].getFullName();
    
                         break;
    this is the error that i get
    *__result = *__first;
    not sure what this means
    any help appreciated

    jessie

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    the code provided seems to be ok.
    Probably problem is somewhere else
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    >> this is the error that i get
    Can you provide the full error text? How is student declared? If it is a vector, what is student.size() ?

  4. #4
    Registered User
    Join Date
    Nov 2006
    Posts
    38
    actually I switched the things being compared and it worked great!

    Code:
    (student[i].getID()== tempID)
    thanks for all this ideas
    jess

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. I need the code of few programs in c++.plzzzzz help...plzzz
    By NAVINKR20 in forum C++ Programming
    Replies: 1
    Last Post: 05-08-2009, 09:13 AM
  2. Search for patterns in source code
    By MiamiCuse in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 10-23-2005, 11:28 PM
  3. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  4. Updated sound engine code
    By VirtualAce in forum Game Programming
    Replies: 8
    Last Post: 11-18-2004, 12:38 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM