6
// compile with a2xis.cc
11
int x = A2x("12"); // initialize int x from a string "12"
12
A2x a2x("12.50"); // explicitly create an A2x object
15
d = a2x; // assign a variable using an A2x object
19
d = a2x; // d is 0: the conversion failed,
20
cout << d << endl; // and a2x.good() == false
22
a2x = " a"; // reassign a2x to new text
23
char c = a2x; // c now 'a': internally operator>>() is used
24
cout << c << endl; // so initial blanks are skipped.
26
int expectsInt(int x); // initialize a parameter using an
27
expectsInt(A2x("1200")); // anonymous A2x object
29
d = A2x("12.45").to<int>(); // d is 12, not 12.45