> #include <iostream.h>
//this is not C any more
#include <iostream>
> #include <string>
> using std::string;
using std::cout;
using std::endl;
//won't compile here otherwise.
>int main()
>{
> string foobar = " ";
>
string foobar; //is equivalent
//string has a default constructor
> cout << "Enter foobar";
>
> cin >> foobar;
>
> cout << foobar;
cout << foobar << endl;
>
> return 0;
>
>}
A lot of C++ compiles when coded like C... but if you want C, use C. I refer mainly to the fact that C++ headers look like <blah> where C headers look like >blah.h> (except for unix system headers).
|