|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
#1 |
|
Member (9 bit)
Join Date: Jun 2003
Posts: 290
|
problem with using classes.
alright. i keep getting this message:
library.h: In member function `void Book::AddBook()': library.h:36: error: no match for 'operator>>' in 'std::cin >> temp->Book::bookID' here is my library.h Code:
#include |
|
|
|
|
|
#2 | |
|
Member (9 bit)
Join Date: Jun 2003
Posts: 290
|
Quote:
|
|
|
|
|
|
|
#3 |
|
Member (9 bit)
|
What language are u using and could u attatch the files or email them to me at fst79ta@gmail.com and i can try and help you if that is c/c++/c#
__________________
|>Sempron64 3000+ @2450 Mhz and counting||1.5 gb AData V-Series RAM||Biostar TForce6100 skt754 || eVGA 7600GT KO 600 core/803 mem|| |> Dual 1.26 GHz Pentium III || 2GB ECC Registered RAM || 18gb scsi 10 HD|| |
|
|
|
|
|
#4 |
|
Member (9 bit)
Join Date: Feb 2005
Posts: 392
|
I think it is Java or C++
anyway, the probelm here is you( ACLerok ) delcared an array of integer in BOOKID: ||||||||||||||||||||||||||||||||||||||||||| class Book { public: char bookName[40]; int bookID[10];<-----------------This is an array of 10 integers!!! int numCopies; Book *next; Book(int=0); void AddBook(); }; ||||||||||||||||||||||||||||||||||| If you want integer with 10 digits you should have used long bookID; if your BOOKID have characters in it: char bookID[10]; got it?
Last edited by alfie2; 05-01-2005 at 06:08 AM. |
|
|
|
|
|
#5 |
|
Member (9 bit)
|
its C++ and it appears to me that the arrays were declared wrong o ill have to get a look at that, its easy to tell it isnt java because the extension for java are .java/.jar/.class and a few others i think but ill get to playing with the code and trying to solve it as soon as i can
|
|
|
|
|
|
#6 |
|
Member (9 bit)
Join Date: Feb 2005
Posts: 392
|
=====================
class Book { public: char bookName[40]; int bookID[10]; int numCopies; Book *next; Book(int=0); void AddBook(); }; ==================== my point is this: if one declare: int bookID[10]; then one can NOT do the following: cout << "\nEnter ID: "; cin >> temp->bookID; <-----trying to insert a number into a pointer is an illegal operation! The following statements are of correct syntax: cout << "\nEnter ID: "; cin >> temp->bookID[0];<---first element in array "bookID" or cin >> temp->bookID[1];<---second element in array "bookID" or : : cin >> temp->bookID[9];<---tenth and last element in array "bookID" ------------ if one try to read a large 10-digit # like 9876543210 then one declares a "LONG" integer or use a "CHAR" array. since the largest signed 32-bit integer is 2147483647 and unsigned is 4294967295 a LONG integer is infinte( well, whatever the system memory can hold anyway) //////////////////////////////////// or you can delcare: char bookID[10]; then the following is totally LEGAL and program compiles/runs fine: cout << "\nEnter ID: "; cin >> temp->bookID; ///////////////////////////////////// |
|
|
|
|
|
#7 |
|
Member (9 bit)
|
yeah i see it was an indexer mmistake it appears these arrays are a little wierd to me since I just switched over to C languages from java but its prety cool I hope u keep at it and have a lot of fun programming
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|