little help in a big way
ok here's the deal. I need to create a class called book which has the following attributes, title(string), publisher(string),number of pages(int)
I figured that out easy enough...but now I need to overload the "<<" somehow? so that the output of the program looks like this...
TITLE: title
PUBLISHER: publisher
NUMBER OF PAGES: num of pages
Also I need to know how to store a file into a vector (think I can do.. pretty much just like arrays) and search the vector/file for a book.
do you see what I mean? I don't really know how to do this and my book isn't being very helpful...
anyhelp would be appreciated
[679 byte] By [
dmegee] at [2007-11-11 9:52:17]

# 1 Re: little help in a big way
Overloading << is going to give you a comparison function for purposes of ordering. What about the books will give you what you want to put them in "order"? Given that, you will want your strings (whichever of the fields you are going to use) to sort themselves in lexicographical order which, in turn, will sort the book objects. Is there a method of the string class which will do that for you?
nspils at 2007-11-11 20:59:49 >

# 2 Re: little help in a big way
Actually, operator < will aloow you to sort the books. operator << is necesssary for diaplying the book using cout. You can read about vector usage here:
http://www.dev-archive.com/dev-archive/LegacyLink/9396
as for iostream operator overloading: http://www.dev-archive.com/dev-archive/LegacyLink/9477
Danny at 2007-11-11 21:00:49 >
