Hello all, I just got the new 13-inch MBP having moved from Windows Vista on a POS HP machine. I had done some basic C++ programming a few years ago, but quickly gave up because of other factors (schooling, etc.) Now that I have more free to time to be able to dedicate to learning this language, I have a few questions since some of the programs I wrote into the Xcode Command Line Tool for C++ aren't working, already.
Now in this book I'm using, which is meant for Windows, it gives an example of a good first program to write:
#include <iostream>
#include <stdlib.h>
int main (int argc, const cha * argv[])
{
cout << "Hello, I am your computer talking." << endl;
system("PAUSE");
return 0;
}
In Xcode 4, the Hello world example is this:
#include <iostream>
int main (int argc, const char * argv[])
{
// insert code here...
std::cout << "Hello, World!\n";
return 0;
}
I am already noticing some differences. Obviously I am new, and don't understand the differences between C++ in a UNIX environment vs. on a Windows environment. The first thing I can tell is different is the lack of "#include <stdlib.h>" line on the Mac example. The second thing I can tell is different is the "std::cout" vs just "cout" on the Windows example program. Why do I need std:: before the cout identifier? When I ran the Windows example without "std::" right before cout or endl I noticed that the compiler had a red exclamation mark with "Use of undeclared identifier 'cout' " nonetheless.
I want to learn C++ on my Mac and develop some programming understanding and was wondering if anyone could help me with the above problems. Really thanks a million in advance, this stuff is very interesting to me but I think I've reached the upper limit of my own problem solving.
Thanks!!!

Now in this book I'm using, which is meant for Windows, it gives an example of a good first program to write:
#include <iostream>
#include <stdlib.h>
int main (int argc, const cha * argv[])
{
cout << "Hello, I am your computer talking." << endl;
system("PAUSE");
return 0;
}
In Xcode 4, the Hello world example is this:
#include <iostream>
int main (int argc, const char * argv[])
{
// insert code here...
std::cout << "Hello, World!\n";
return 0;
}
I am already noticing some differences. Obviously I am new, and don't understand the differences between C++ in a UNIX environment vs. on a Windows environment. The first thing I can tell is different is the lack of "#include <stdlib.h>" line on the Mac example. The second thing I can tell is different is the "std::cout" vs just "cout" on the Windows example program. Why do I need std:: before the cout identifier? When I ran the Windows example without "std::" right before cout or endl I noticed that the compiler had a red exclamation mark with "Use of undeclared identifier 'cout' " nonetheless.
I want to learn C++ on my Mac and develop some programming understanding and was wondering if anyone could help me with the above problems. Really thanks a million in advance, this stuff is very interesting to me but I think I've reached the upper limit of my own problem solving.
Thanks!!!
