The one I found online uses std:: cout << '\n'; or something like that.
Just make it std::endl and continue with the book. Occasionally there will be typos that you have to figure out. That errata isn't much help for the 5th edition, sorry.
The one I found online uses std:: cout << '\n'; or something like that.
Just make it std::endl and continue with the book. Occasionally there will be typos that you have to figure out. That errata isn't much help for the 5th edition, sorry.
Another lame question.
Do you have to do each section a day?.. Or can you go on to other sections and complete and still grasp all their information, in one day?... Heh I know I guess this is personal choice, just curious.
I'd say, if you think you can continue, and still grasp what they're teaching, go ahead. If you finish the book before the "21 days" are up, go through it again. It will only serve to solidify it in your mind.
Now, for more error fixing:
Also, I would second second the motion to use "using namespace std;" because the code would then look like this:Code:#include <iostream> int main() { int x = 5; int y = 7; std::cout << std::endl; std::cout<< x + y << " " << x * y; std::cout<< std::endl; char response; std::cin >> response; return 0; }
A bit cleaner and clearer, eh?Code:#include <iostream> using namespace std; int main() { int x = 5; int y = 7; cout << endl; cout<< x + y << " " << x * y; cout<< endl; char response; cin >> response; return 0; }
Tell me, what is the purpose of having "cin >> response;" in there? There's nothing to respond to. If that's supposed to be a trigger to keep the program from exiting automatically, just replace it with " system ("pause"); ". That way, you don't have to declare an extraneous variable.
No matter how long it takes you to go through the book (it should probably take more than 21 days, though), you should get a different book and go through that to augment your learning. There are only a few books that teach modern C++, and Liberty's book is not one of them (even though Brad Jones has said that he has tried to get it updated... it hasn't happened yet).
The perfect book to follow up with is Accelerated C++ by Koenig and Moo. It might even be smart to switch to that now, if you are really interested in learning good modern C++ practices and techniques rather than general programming skills.
BTW, I personally prefer to add std:: to all names in the std namespace. It is more consistent because there are situations where a using directive is bad practice. I also find it easier to read despite the added clutter.
I look forward to the time when I encounter that situation myself.
using namespace std is bad practice in a header file. So now that you are starting to use other headers you have already found such a situation.
So you only want to use it in the .cpp files? If then, I'm guessing?
I always use std:: in all files, header or source. It is bad practice to use the "using namespace std" in a header file. It is usually fine to do it in a source file, but I prefer to be consistent and do it in neither. For simple beginner code it really doesn't matter much at all, although it is wise to follow good habits for the future.
its better to start with a more simple language than c or c++. I would start with a flavor of basic do to the lack of cryptic language. That way you can get a hold on programming in general with out all the cryptic words etc. Once you learn how syntax works etc you can learn pretty much any language with out the hassle of remembering all the tricks of a hard language as well as learning how to program.
-- Will you show me how to c++?