![]() |
|
#1
|
|||
|
|||
Help with compiler errors**My code does NOT complile...I need help on the compile errors**
1. error C2676: binary '==' : 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' does not define this operator or a conversion to a type accep table to the predefined operator 2. error C2440: '=' : cannot convert from 'class Seller *' to 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast **Having problems with entering info(string) about the items to be auctioned, search using an id number and remove...when i enter the string it gives me binary back when i dont have the compile errors...Please help I do not understand my compile errors ****MY CODE(part)*** CPP / C++ / C Code:
Last edited by LuciWiz : 31-May-2005 at 14:34.
Reason: Please insert your C++ code between [c++] & [/c++] tags
|
|
#2
|
||||
|
||||
|
If you can include line numbers with future error messages (your compiler should report this, I think), it will be easier to address your questions.
The code as you posted it caused a few other compile-time errors for me, using g++ 3.3.5. In the following line CPP / C++ / C Code:
Commenting out the ": public User" part and moving on, I also found that the "remove" and "seqSearch" methods did not specify a type for the parameter "idNum". CPP / C++ / C Code:
CPP / C++ / C Code:
Code:
CPP / C++ / C Code:
The second error message is similar. It refers to the line CPP / C++ / C Code:
I hope this helps, and will be happy to try answering other questions (including those about my lengthy answers Matthew |
|
#3
|
|||
|
|||
compiler errors to MatthewI understand you can not compare strings to ints BUT I guess what im tryin to ask is that how do i search for a string by using the idNum....for example
Please enter the id number for the item u want to delete id number is entered if id number is equal to the idnumber entered delete if not make sense tell me PS my whole code wasnt listed user is a class defined sorry |
|
#4
|
||||
|
||||
|
So, you want each item that is for sale to have a (presumable unique) ID number associated with it. I notice that each Seller also has its own ID number. In this case, try using more specific variable names to avoid confusion over which ID number is in question.
Now for your problem of finding items in the list by ID... As with any problem, programming included, there are several ways to do this; I will mention two that I can think of, but you may be able to come up with your own that suits your problem better. Method 1) Keep multiple "lists" (or arrays), one for item name, one for item ID, etc. In this scenario, you need to make sure that all the lists are synchronized; that is, they have the same length, and when you add/remove/modify one list that you also do the same for the others. While this can work, I find it tedious, error-prone, and do not recommend it, though it may seem like more work initially to design the Item class and how it should interact with the rest of your program. Method 2) Create a new structure for items, for example "class Item". This class will contain the string name of the item, the ID number, etc. THen you require only one list, which could then be an array of Item objects. Of course, you need to consider all kinds of new things, such as how to create an Item (with a constructor that takes a string, int, etc. as parameters), and how to retrieve the name, or ID, from the Item object if necessary. I recommend this method. I'll be happy to clarify if you don't quite follow me here. Matthew |
Recent GIDBlog
Observations of Iraq by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| C++ PhoneBook | marita | C++ Forum | 46 | 12-Jun-2005 12:10 |
| Newbie : need help with Dev-C++ compiler | batrsau | C++ Forum | 2 | 20-Mar-2005 21:05 |
| compiler errors | Newworld | C Programming Language | 1 | 28-Oct-2004 07:07 |
| help to debug complier errors | nkhambal | C Programming Language | 3 | 04-Oct-2004 08:26 |
| a noobish compiler question | Charunks | C++ Forum | 5 | 03-Sep-2003 02:18 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The