Hi all, I'm mainly trying to get back some of the basics of C that I learned many years ago, but just for fun, I tried a basic "Hello World" type program in C++ just to see if I could do it.
Turns out it's harder than I expected. I'm using g++ in Terminal.
My first attempt (based on original source code):
This gave me a curt error message:
Then I tried again, changing only the line:
#include <iostream>
to
#include <iostream.h>
And it gave me a bunch of warnings about deprecated or antiquated header file names.....BUT...the code compiled fine!
So if you're *supposed* to use just <iostream>, why did I get the initial error, and how do I correct that?
Thanks for any help
Turns out it's harder than I expected. I'm using g++ in Terminal.
My first attempt (based on original source code):
Code:
#include <iostream>
main ()
{
cout << "Hello World, I'm a C++ Program!\n\n";
}
This gave me a curt error message:
Code:
first.cc: In fuction `int main()`:
first.cc:5: error: `cout` was not declared in this scope
Then I tried again, changing only the line:
#include <iostream>
to
#include <iostream.h>
And it gave me a bunch of warnings about deprecated or antiquated header file names.....BUT...the code compiled fine!
So if you're *supposed* to use just <iostream>, why did I get the initial error, and how do I correct that?
Thanks for any help