This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: stringstream >> assignment
- From: Jeffrey Walton <noloader at gmail dot com>
- To: fsshl at att dot net
- Cc: gcc-help at gcc dot gnu dot org
- Date: Wed, 6 Jul 2011 03:19:28 -0400
- Subject: Re: stringstream >> assignment
- References: <1309936364.3468.3.camel@eric-laptop>
- Reply-to: noloader at gmail dot com
On Wed, Jul 6, 2011 at 3:12 AM, eric <fsshl@att.net> wrote:
> Dear advanced g++ program:
>
> ?I copied a simple template and streamstring code from book, c++
> cookbook, at chapter 3 section 5.pg131: Parsing a string containing a
> Number in Scientific Notation.
> -----------------------------------------------------------
> #include <iostream>
> #include <sstream>
> #include <string>
>
> using namespace std;
>
> //double sciToDub(const string& str) {
> ?template<typename T>
> ?T strToNum(const string& str) {
>
> ?stringstream ss(str);
> ?T tmp;
> ?ss >> tmp;
>
> [SNIP]
>
> ?}
> ?catch (string& e) {
> ? ?cerr << "Whoops: " << e << endl;
> ?}
> }
> ------------------------------------------------
> my test result is all 4 output is 7
> why is that, especially first two, double and float?
comp.lang.c++ is probably a more appropriate group.