H
halkun
Guest
Ok, So I have decided to attempt OO programming *again* with C++. I doug through my bookshelf and found my "Teach Yourself C++ in 21 Days" book, and took to writing my first "Hello World" prorgam.
Code: [Select]
g++ barfed on this at compile time.
Guess what, iostream.h seems to be deprecated! That lib is, like, in every single C++ tutorial I've ever seen! It would seem that I have to make some changes to *EVERY* example in my book, and get around things one of two ways.
First, I have to change <iostream.h> to <iostream>.
then I have type
Code: [Select]
after my modified #include <> statement. This "kinda fixes" the cout command, but I can't seem to get this to work.
Code: [Select]
Which is an example in the book to make a new line.
Other than that I can drop the "namespace" thingy and then have to tell the compiler to use cout like this..
Code: [Select]
Now it seems that when you use the "std::" method, I have to prefix not only "cout" but other functions like "endl" with this "std::" thing. (Whatever that means, I'm guessing it has something to do with 'namespace' and telling it to use "std", but as I don't know what namespace is either, or what 'std' referrs to, or why I need to seperate these two commands with a double-colon, so that doesn't help me in the least.)
This isn't going so well for my first day. I can compile 20 year old C programs in gcc, but I can't compile a 6 year old C++ program?
I'm continuing anyway, but I'm going to have to rewrite code when I come across it, not knowing what it does. Is there any other issues I'm going to have to worry about. It seems that basic I/O commands have changed an I'm probably going to be banging my head aginst the wall then it comes to input or even *gasp* accessing a file!
Little help here?
Code: [Select]
Code:
#include <iostream>int main(){ cout << "Hello World!\n"; return 0;}
g++ barfed on this at compile time.
Guess what, iostream.h seems to be deprecated! That lib is, like, in every single C++ tutorial I've ever seen! It would seem that I have to make some changes to *EVERY* example in my book, and get around things one of two ways.
First, I have to change <iostream.h> to <iostream>.
then I have type
Code: [Select]
Code:
using namespace std;
Code: [Select]
Code:
cout "\n";
Other than that I can drop the "namespace" thingy and then have to tell the compiler to use cout like this..
Code: [Select]
Code:
std::cout << "Whatever.\n";
Now it seems that when you use the "std::" method, I have to prefix not only "cout" but other functions like "endl" with this "std::" thing. (Whatever that means, I'm guessing it has something to do with 'namespace' and telling it to use "std", but as I don't know what namespace is either, or what 'std' referrs to, or why I need to seperate these two commands with a double-colon, so that doesn't help me in the least.)
This isn't going so well for my first day. I can compile 20 year old C programs in gcc, but I can't compile a 6 year old C++ program?
I'm continuing anyway, but I'm going to have to rewrite code when I come across it, not knowing what it does. Is there any other issues I'm going to have to worry about. It seems that basic I/O commands have changed an I'm probably going to be banging my head aginst the wall then it comes to input or even *gasp* accessing a file!
Little help here?