Xcode doesn't let me initialize values in C++ -
i'm using stroustrup's book programming -- principles , practice using c++ pick c++. 1 of topics regards initializing variables. consider following example in book:
#include <iostream> #include "std_lib_facilities.h" int main() { cout << "please enter first_name , age\n"; string first_name = "???"; // string variable // ("???" means "don't know name") int age = -1; // integer variable (-1 means "don't know age") cin >> first_name >> age; // read string followed integer cout << "hello, " << first_name << " (age " << age << ")\n"; }
in code, variable age supposed initialized -1. however, in xcode, when tried build , run it, age set 0 when typed in that's not integer age. example, if type in "22 carlos", script returns 0 age. according book, i'm supposed see -1.
i'm using xcode ide. have ide?
Comments
Post a Comment