New to C++ help with simple script
As the label says c++ is my first language other then php. im reading around through a book and to test a compiler i have a test scripts
#include<iostream> int main() { std::count << "hello world\n"; return (0); } howerver when i run it with CC -g otesting hello.cpp i get the following error Quote:
Quote:
Is this book maybe to old or is there something i need to configure? thanks |
It should be std::cout, not count. Edit: I'm not sure if you should be using cc to compile C++, I thought that was just a C compiler. Try g++.
|
Thanks, yea reading through the book they let you know of all compilers but gives little to none on which one you should use. And that cout was my own doing ><
thanks =D //edit since i got you here mind if i add a few more questions? Thought the book most work is done with some IDE is it ok that i just write my scripts in xemacs or is there a downside to this? if there is what type of ide should i use? thanks |
To compile hello.cpp into an executable called hello, you use "g++ hello.cpp -o hello". Which book is it that you have?
|
Practical C++ programming
|
Quote:
|
Hmm, I've not got "Practical C++ Programming" myself, but it seems to get mixed reviews (at least on Amazon).
|
Practical C++ Is a great book, I Love all O'reilly books. But it seems a lot of programming books get mixed reviews depending on how much knowledge you have on the subject before reading the book. I had a good grasp of C++ and have been programming in C and similar languages e.g. Java for a few years before reading it, so mileage may vary.
I do like how it gives you little tasks to try, they are similar to the labs I had in my CSE classes a few years ago. They even touch on making your own data structures, essential to any good programmers tool box. I find myself still picking up the book for reference and to reread certain areas. By the way, I picked up mine for only about $5 with shipping on half.com. Good stuff. |
Read up on GCC. There's a couple of nice chapters in "Running Linux" by Welsh et. al., and there is of course the manual.
By the way, you can get rid of the parentheses () around 0. For beginner C++ books, if you have a little bit of programming knowledge (even if it's in unrelated languages), the following books are greatly recommended: "Accelerated C++: Practical Programming By Example" by Andrew Koenig and Barbara E. Moo "C++ Primer (4th edition)" by Stanley B. Lippman et. al. If you have C knowledge, then you might try: "Thinking in C++, Volume 1: Introduction to Standard C++ (2nd Edition)" by Bruce Eckel And, of course, at some stage you must get the bible: "The C++ Programming Language (3rd Edition)" by Bjarne Stroustrup ("da man") Once you have passed the beginner's stage, and have entered the intermediate stage, you should try most of these books: "C++ Common Knowledge: Essential Intermediate Programming" by Stephen C. Dewhurst "C++ Coding Standards: 101 Rules, Guidelines, and Best Practices" by Herb Sutter and Andrei Alexandrescu "The C++ Standard Library: A Tutorial and Reference" by Nicolai M. Josuttis "Modern C++ Design: Generic Programming and Design Patterns Applied" by Andrei Alexandrescu I also recommend two series, Herb Sutter's "Exceptional" series: "Exceptional C++: 47 Engineering Puzzles, Programming Problems, and Solutions" by Herb Sutter "More Exceptional C++" by Herb Sutter "Exceptional C++ Style : 40 New Engineering Puzzles, Programming Problems, and Solutions" by Herb Sutter and Scott Meyers' "Effective" series: "Effective C++: 50 Specific Ways to Improve Your Programs and Design (2nd Edition)" by Scott Meyers "More Effective C++: 35 New Ways to Improve Your Programs and Designs" by Scott Meyers "Effective STL: 50 Specific Ways to Improve Your Use of the Standard Template Library" by Scott Meyers As for programming tools, there's nothing wrong with using vi or emacs for editing and make for project management. But there's also nothing wrong with using Anjuta or KDevelop. Try them all out until you find something you're comfortable with. Read, code, code, read, code, code, code, read, code, read, code, code, read, code, code ... and soon enough you will become smart thinkink C++ guru with evil Slavic accenkt! |
For a beginner, I recommend "Beginning ANSI C++: The Complete Language" by Ivor Horton. Personally, I find it very easy to follow and it doesn't require any previous programming experience.
|
All times are GMT -5. The time now is 11:49 PM. |