Re: Error: "no match for operator" when building an array of Books

Posted 21 March 2011 - 12:20 PM

I've erased those sorry.

The first error is in line 10:
Book[] b =new Book[10];
and it says: no match for 'operator='in 'b=(std::basic_string<char,char traits<...

Actually I think that I am not building that array of books properly....we were shown several methods in class , but they only confused me, and I have tried some of them, which resulted in a very messy code.....

Re: Error: "no match for operator" when building an array of Books

Posted 22 March 2011 - 06:28 AM

You have many errors in the code you posted.

Quote

at line 19: error void book::set(Book)' can not be overloaded

In your Book.h file in your class definition you have defined a member function named set() twice with the same type and numbers of parameters. If you want to overload a function then the definitions must be different. But you probably just want to delete one of these lines.

In your implementation file your constructor never initializes your member data variables. Also the use of the same name for the parameters and the member data variables will cause problems. If the names are the same then you must use the member resolution operator (this->title) to distinguish between the parameter and member variable.

Re: Error: "no match for operator" when building an array of Books

Posted 22 March 2011 - 07:22 AM

Quote

Also is there any reason that you are trying to use dynamic memory to declare your Book array, instead of just statically defining the Book array?

Jim

well I don't really know the difference, This is the method we were shown during the laboratory, I don't know how to use another one. My knowledge of C++ is rather limited. But I'll use your suggestions as well as I can.