Help with comparsion of two objects

This is a discussion on Help with comparsion of two objects within the C++ Programming forums, part of the General Programming Boards category; Note that ISBN can end with an X since they use a checksum that generates 11 values, and uses 0-9 ...

  1. #16
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Note that ISBN can end with an X since they use a checksum that generates 11 values, and uses 0-9 + X as the values for that. (X being ROMAN 10, I suppose?)

    Of course, it's not hard to replace isdigit with "isisbn", and produce a function chat checks for "isdigit", and if it isn't, checks for 'X'. Just make sure you make it uppercase first (or allow lowercase, but if you are going to "massage" the string in the first place, you may just as well convert it too).

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  2. #17
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    Of course, it's not hard to replace isdigit with "isisbn", and produce a function chat checks for "isdigit", and if it isn't, checks for 'X'. Just make sure you make it uppercase first (or allow lowercase, but if you are going to "massage" the string in the first place, you may just as well convert it too).
    Of course, you'd be best off calling such a function is_isbn(), since identifiers beginning with "is" followed by a lowercase letter are reserved because of ctype.h/cctype (in C at least, and I don't see why C++ would be any different).
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 60
    Last Post: 12-20-2005, 11:36 PM
  2. Question about cout an stack object?
    By joenching in forum C++ Programming
    Replies: 8
    Last Post: 05-08-2005, 11:10 PM
  3. chain of objects within pop framework help needed
    By Davey in forum C++ Programming
    Replies: 0
    Last Post: 04-15-2004, 11:01 AM
  4. Replies: 4
    Last Post: 10-16-2003, 12:26 PM
  5. array of objects?
    By *~*~*~* in forum C++ Programming
    Replies: 4
    Last Post: 05-31-2003, 06:57 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21