c++ equivalent to java's Integer class

This is a discussion on c++ equivalent to java's Integer class within the C++ Programming forums, part of the General Programming Boards category; I'm a Java programmer starting out with C++. I'm reading input from a text file with each line in the ...

  1. #1
    Registered User
    Join Date
    Aug 2008
    Posts
    3

    c++ equivalent to java's Integer class

    I'm a Java programmer starting out with C++. I'm reading input from a text file with each line in the form of a date like "12/03/1990". I need to validate the month in the range of 01-12. In Java I would do this:

    Code:
    String s = "12/03/1990";
    String ss = "";
    for (int i=0;i<2;i++) {
    ss += s.charAt(i);
    }
    int n = Integer.parseInt(ss);
    boolean x = (n >= 1 || n <= 12) ? true : false;
    Is there a class in C++ that can parse a string for numbers?

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    stringstream seems to be what you want.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. No Match For Operator+ ???????
    By Paul22000 in forum C++ Programming
    Replies: 24
    Last Post: 05-14-2008, 10:53 AM
  2. class composition constructor question...
    By andrea72 in forum C++ Programming
    Replies: 3
    Last Post: 04-03-2008, 05:11 PM
  3. structure vs class
    By sana in forum C++ Programming
    Replies: 13
    Last Post: 12-02-2002, 06:18 AM
  4. Abstract class problem
    By VanJay011379 in forum C++ Programming
    Replies: 9
    Last Post: 07-31-2002, 01:30 PM
  5. Equivalent of Java's "super" keyword
    By JasonLikesJava in forum C++ Programming
    Replies: 6
    Last Post: 05-31-2002, 10:21 AM

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