DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: little help in a big way

  1. #1
    Join Date
    Oct 2006
    Posts
    4

    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

  2. #2
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    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?

  3. #3
    Join Date
    Nov 2003
    Posts
    4,118
    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.devx.com/DevX/LegacyLink/9396
    as for iostream operator overloading: http://www.devx.com/DevX/LegacyLink/9477
    Danny Kalev

Similar Threads

  1. Mysql or PostgreSQL? Big tables
    By wakeup in forum Database
    Replies: 0
    Last Post: 05-23-2006, 04:33 AM
  2. Big Integer and primitive roots
    By xxxxx in forum Java
    Replies: 1
    Last Post: 04-05-2005, 11:17 AM
  3. MLM With A Big Difference - Rs. 60/- to join.
    By Shivani Arora in forum Careers
    Replies: 0
    Last Post: 06-04-2003, 10:43 PM
  4. The big question
    By Jon Morgan in forum Talk to the Editors
    Replies: 1
    Last Post: 01-02-2003, 06:01 PM
  5. Big consulting firms?
    By CProgrammer in forum Careers
    Replies: 2
    Last Post: 06-07-2001, 10:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center