No, you don't. ''Yes, I do.'' Trust me on this. You can't learn C++. No one can learn C++. ''You mean you can't learn it.'' No, I did learn it. I spent a long time learning it. And for a while I knew it as well as anyone. But I don't work in it any more and really no one works in C++ any more. ''There's a whole buncha code written in C++, dopey. People work on it.'' AlternateHardAndSoftLayers ate C++ alive. Small standalone optimizations of SoftLanguage features still get written in C++. But why do you wanna write them? Learn ruby or smalltalk or python - all the same thing now really - and forget the C++. Or go learn C#. Or even java. But really, if you don't already know it, learning C++ is about as useful to you as learning Latin. ''...Unless you're developing action games, or embedded apps, or any other environment where you need high performance and a giant monolithic interpreter is not an option.'' -- AC [True. I just asked one of my academic colleagues -- whose industrial background and current teaching & research area is games, in particular the console and PC games industry -- to what degree one could get by without C++. His answer was that "They (the industry) won't even look at you." I asked him about use of Ruby, Python, etc. They are being used, but only in conjunction with C++. In such cases, you're expected to know both the hard and soft layers. You still need, at the very least, to have C++ on your CV/resume.] -- DaveVoorhis ---- People new to programming sometimes have the impression that C++ is '''the''' modern programming language. If you don't already know an OO programming language, check out IwannaLearnPython, FreshmansFirstLanguage, or AlternativesToCeePlusPlus. C++ is not a good learning language. That's not to say C++ is a bad language - it's very good at what it's designed for (compatibility with C, and execution speed). ''Compared to CeeLanguage, CeePlusPlus is (a CeeVsCpp page might be useful...)'' So you wanna learn CeePlusPlus. What you should first answer is: Do you want to (or should) learn C++, or a mishmash of C++ and CeeLanguage, or EarlyCeePlusPlus, or LateCeePlusPlus, or another language entirely? ''Huh? If I don't *already* know C++, how in the world am I supposed to answer this question without flipping a coin?'' Will you be working with legacy mishmash code or coding from scratch? Are you coming to C++ from previous knowledge of C, coming from other programming languages, or coming as a first-time programmer? Also, what does your compiler expect? If you're not so sure you wanna learn C++, there ''are'' AlternativesToCeePlusPlus, you know. Most people learn faster alternating between hand-on coding and reading, rather than reading some thick book in its entirety before touching the keyboard. Get a decent C++ compiler and C++ IDE (they will also work just fine for compiling plain C programs), and you can start pounding out code with CeeProgramsForBeginners. Then grab one of these books and go through the exercises. '''Books''' * ''Accelerated C++,'' by AndrewKoenig and BarbaraMoo (ISBN 0-201-70353-X) 2000. A new approach to teaching CeePlusPlus, which focuses on using the C++ Standard Library (such as std::string, std::vector, etc.) to actually accomplish tasks, as language features are introduced slowly with numerous examples and exercises. A very good book. * ''C++ for Programmers, 3rd ed,'' by Leen Ammeraal and Hogeschool van Utrecht (ISBN 0-471-60697-9) June 2000. Teaches ANSI-standard CeePlusPlus with the new ''string'' type, new #include convention, namespaces, StandardTemplateLibrary, etc. CeeLanguage libraries and old-fashioned C++ style are relegated to the final chapter. Because the examples are trivial, it's not going to teach a first-time programmer to create something fun or particularly useful. But it's satisfactory for programmers coming from a background in other languages or EarlyCeePlusPlus and wanting to get the hang of pure LateCeePlusPlus. * Sams ''Teach Yourself C++ in 24 Hours'' by Jesse Liberty (ISBN: 0-672-32224-2) is 24 1-hour lessons in CeePlusPlus. It is hard going for beginners but doable. Comes with Bloodshed/Dev-C++ compiler. ''Tips: run examples in DOS (or insert a "system("PAUSE");" just prior to the return) or you'll never see the results.'' Teaches purely LateCeePlusPlus. One chapter is an overview of industry practices and troubles: WaterfallModel, ExtremeProgramming, UmlDiagram''''''s, UserStories, code rot, etc. * BruceEckel's ''Thinking in C++, volumes 1 & 2'' (download them from http://mindview.net/Books/TICPP/ThinkingInCPP2e.html) Recommended reading for StandardTemplateLibrary. Quoted from StlStyle: "He has a clear grasp of good STL use and a very readable explanatory style." * ''Teach Yourself C++'' by Al Stevens (ISBN: 0-764-52644-8). I learnt CeePlusPlus from this book way back when it was in its second edition, circa 1987. I then had very little to do with C++ till I took my current job in 2003. With the help of the seventh edition of this book, I was able to quickly bone up on C++ and fake my way along. My unsuspecting teammates think I'm an absolute whiz at C++ with 15+ years experience in it - little do they know. -- AnonymousDonor * Hubbard, John R. 1996. ''Schaum's outline of the theory and problems of programming with C++''. ISBN 0-07-030837-3. (I think there is a smaller newer version.) An aging beginners/student programming book, but I did find it readable as a basic introduction to the mechanics of C++, containing logical examples which test out the basic mechanics of classes, inheritance, templates, etc showing screen output - so reading is somewhat like having typed & tried it out oneself (without the advantage of trying your own things admittedly). No harm in knowing the old code, if you don't stick on old C methods (eg arrays v vectors); code you see is often old. You update yourself to namespace etc easily. * The StandardTemplateLibrary and StlStyle pages recommend some books about STL. * others?... '''Tutorials''' * "How To Think Like a Computer Scientist" in C++ (http://ibiblio.org/obp/thinkCS/cpp.php). This tutorial written for students preparing for the College Board AP exams in Computer Science (AmericanCulturalAssumption) assumes no previous programming knowledge... but it's not "for Dummies." Instead of the new ''string'' type and the StandardTemplateLibrary, it uses a non-standard, yet downloadable, library for string, vector, matrix, stack, and queue handling. (It seems this is the library the College Board expects hopeful CS majors to know.) This tutorial doesn't bother with old C idioms and functions, yet it also doesn't bother to mention namespaces and the new C++ way of including standard headers. The writing is not boring, the later code is not trivial, and it plays Old Maid! * C++ Tutorial from cplusplus.com (http://www.cplusplus.com/doc/tutorial/). Haven't read it. Anyone care to review it or delete it here? ''Definitely outdated. Any tutorial which still uses #include (instead of #include) and uses 'cout' without qualifying it with the 'std' namespace is considered very outdated and hence not at all recommended. The tutorial has lots of other problems also.'' * Other online resources can be found at DMOZ OpenDirectoryProject ( http://dmoz.org/Computers/Programming/Languages/C%2b%2b/FAQs,_Help,_and_Tutorials/) * others?... '''C++ vs C header files and compiler issues''' * ANSI C++ Standard header files compared with C header files: http://www.cplusplus.com/doc/ansi/hfiles.html. * How may I know if my compiler supports ANSI-C++? If you have doubts, check if your compiler supports the ''bool'', ''using namespace'', and ''template'' keywords. You can use a program like the following one to do so: ''(from http://www.cplusplus.com/info/faq.html)'' #include using namespace std; template bool ansisupported (T x) { return true; } int main() { if (ansisupported(1)) cout << " ANSI OK "; return 0; } ---- '''CeePlusPlus subtleties''' ''rescued from defunct Cee''''''Plus''''''Plus''''''Subtleties'' ---- while(*dest++ = *src++); '' '''Very''' bad style. Always, always, always use "continue":'' while (*dest++ = *src++) continue; ''And it is idiomatic more than it is subtle.'' For this particular code, it would be better (and faster on most machines) to use the library routine strcpy(). Even better - the library routines strncpy(), or even better strlcpy(). See CeeLanguage for details. ''But strlcpy() is not a part of C Standard.'' ---- ''For the "real" subtleties, there are many fine books such as StructureAndInterpretationOfComputerPrograms, ModernCeePlusPlusDesign, OnLisp and the likes. Of course, they are in languages that allow and encourage subtle things, and more importantly, they're not subtleties for the sake of being "subtle", but smart, elegant designs that make code better and the life of the coder enjoyable.'' A few subtle, difficult, topics for CeePlusPlus: * object lifetimes (static objects, temporary objects) * sequence points * partial ordering of template specializations ---- Another subtlety, because arrays are SyntacticSugar for pointers in C/C++, is that square brackets are commutative. a[5] = 5[a]. The former is *(a+5), the latter *(5+a). ''No, that is not true - arrays are not *just* SyntacticSugar for pointers, they are very different. Google the C++ Usenet groups for a comprehensive discussion on why they should not be considered as the same.'' ''But 5[a] is universally considered bad C/C++ style, so it's pointless. The fact that a[5] is *(a+5) is the main point, and it's not all that subtle.'' An array is a constant, you cannot perform a++ (referring to the a[] above), unlike a pointer which may be incremented, thus the difference is not of syntactic sugar for this reason. -- DavidMXGreen ''This doesn't show that it's not SyntacticSugar. You can't perform a++ on a const pointer either.'' ---- Simple solution: don't use arrays. When coding modern C++, arrays should be thought of the same as the "unsafe" operations in C#, or modifying builtin objects in Python - something you use only when you must. In the case of C++, this is during hardcore optimization, or if your compile times are getting too freakishly long, or when implementing your own containers from scratch when the standard library is unavailable. Otherwise, use Vector<>. C++ is not a horrible language if you learn modern C++ with heavy use of BoostLibraries and StandardTemplateLibrary (STL) - in the end, it feels like a somewhat verbose C#2 with some weird extra gotchas (the real problem), annoying layout (the header/linker crap) and stack-based destruction (actually allocating objects on the heap is more rare than you'd think in well-structured C++). If you stick to some solid "best practices" and stuff most of the old C language in a box labelled "unsafe" you can do fine. ---- As far as you have read through all this page, either you would escape threatened, or you would conclude that all these people are so freaked out. You started as a genuine novice that wanted to learn, and ended in an odd discussion about 5[a]. My relationship with C++ is like the one of gollum love/hate to the ring: "We swears to serve the master of the precious. We will swear on... on... the precious!" I started 10 years ago dreaming about C++, learned it, or still learning it. Is the most powerful and more odd language you may ever encounter. The language itself contains 5 or six different dialects variants, and you can build your own. The most beautiful part of it is that you can design within the code. The ugliest is the standardization, why the heck we are standardizing && and we don't have a decent standard library for widgets, xml or http? Is that possible that nobody has ever written a clean implementation of these in the last 20 years? ---- If you manage to become competent in C++ and even have some expertise in it, the effort that went into doing so won't be wasted even if you never use the language again. After C++, learning any other programming language will seem easy. ---- See also CeePlusPlusRoadMap ---- OctoberZeroSix CategoryCpp, CategoryBooks, IwannaLearn