Get back to basics. How do I get back into C++? [closed] - c++

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I haven't used C++ since college. Even though I've wanted to I haven't needed to do any until I started wanting to write plugins for Launchy.
Is there a good book to read to get back into it?
My experience since college is mainly C# and recently ruby. I bought some book for C# developers and it ended up being on how to write C++ with CLI. While a good book it wasn't quite what I was looking for.

My favorites are Effective C++, More Effective C++, and Effective STL by Scott Meyers. Also C++ Coding Standards by Sutter and Alexandrescu.

The best way to get back into C++ is to jump in. You can't learn a real language without spending any serious time in a country where they speak it. I wouldn't try to learn a programming language without spending time coding in it either.
I wouldn't recommend learning C first though. That's a good way to pick up some bad habits in C++.

I haven't tried it myself but have heard from people and sources I trust that "Accelerated C++" by Koenig and Moo is a good book for people who want to pick up C++ quickly. Compared to the more traditional route of learning C first then C++ as a kind of C with classes the K+M approach helps you become productive quickly while avoiding pitfalls and bad habits associated with the legacy of the language.

A good starting place is "Thinking in C++" by Bruce Eckel, I've rarely had anyone complain about the book. Well written and also has a version available online.

Another online book that I pick up whenever I need to get back into C++ is "C++ In Action" by Bartosz Milewski. Its online at his site.

The C++ Programming Language by Bjarne Stroustrup covers C++ in depth. Bjarne is the inventor of C++. It also provides insights into why the language is the way it is. Some people find the book a little terse. I found it to be an enjoyable read. If you have done some C++ before it's a great place to start. It is by no means a beginners book on C++.

My book recommendations:
Essential C++ (Lippman)
C++ Common Knowledge: Essential Intermediate Programming (Dewhurst)
...and I second the Effective C++ suggestion above.
A very handy alternative to buying books in meatspace is to subscribe to a service like Safari Books Online. For a not unreasonable monthly fee you'll get access to all of the above books plus a bajillion others. If you desire fast random access to more than a couple books, it pretty much pays for itself. It's an easy case to make if you want to convince your employer to pay for it.
Beyond that, sit yourself in front of an IDE that has a C++ code completion feature (I use Eclipse/CDT most of the time).

Related

Is learncpp.com good for beginners? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
In my search for a good, freely available resource that will teach me C++ I stumbled on http://www.learncpp.com/.
My question is for intermediate to experienced C++ programmers...
Does this site seem to be a good resource for a beginner to learn C++ from?
I've gone through the first few section of the site, and I feel like I am starting to grasp the language, but being a beginner in C++ I really could be learning things all wrong and have no idea.
EDIT: After doing some research on this topic, and reading the answers and comments here, it seems like if I do the tutorial, read Accelerated C++, and then read Effective STL... I'll be on the right track. Of course, I'll be writing programs to solve project Euler programs and such. Do any of you have a better idea for a beginner with intentions to become competent in the language?
The site does not look too bad.
However it really is a tutorial, in that it just explains the very basic concepts of C++.
Notably, it completely misses an introduction to the STL and the proper use of it. You barely see std::cout and std::string. There's no mention of <algorithm> that I could see of and no mention of the <vector> or <deque> or <map> which are the most commonly used containers in C++.
It may not hurt you to learn with this site, but you'll only have a very basic level when you're done with it.
If you want to learn C++ the right way I strongly recommend you purchase a copy of Accelerated C++. It is the best C++ book for a beginner without a doubt.
Although the few pages I looked at seem reasonable, any instruction on C++ that recommends the use of Hungarian Notation completely misses the point and is thus suspect.
This site doesn't look too bad, but I don't think it's great either. A great free resource to learn C++ is the book "Thinking in C++". It's simply outstanding and I heartily recommend it to you. The other thing I recommend you is to start writing some code in C++ right now! Project Euler is my favourite source for beginners programming tasks(especially if you like math ;-) )
When I was in the university I was using the http://cplusplus.com/. I was quite satisfied with everything there.
It doesn't hurt to start of learning a language through a tutorial, but keep in mind that a tutorial may not (will not) cover all topics of a language. There are always better things than tutorials, like a book and a compiler.
I would recommend that you base your study on a good book like The C++ Programming Language
(Third Edition and Special Edition) by the creator of C++ Bjarne Stroustrup.
It doesn't necessary have to be this book, it can be any useful book that other programmers have used and learned from. Books are also programmers tools.
I'm currently reading the C++ tutorial at learncpp.com and think it's great!
For a C++ beginner, like me, that is. You won't get all the answers, but do you really want that as a C++ beginner? I would say no. At least, I don't.
What you will get are lot's of short answers to questions about basic C++ concepts, that I believe will be helpful when you later learn about other aspects of C++.
As I said, I'm a C++ beginner, but I have used PHP for several years. I would't say I'm a PHP expert, but I'm not a beginner either, so I think I more or less know what I'm talking about when it comes to languages resembling PHP, like C++.
Yes.
The tutorials have a comment section, and the admin seems to be responsive to questions there. This indicates that there is some accountability for the material in the lessons.
I have been using C# for several years... Sometimes I have to work with legacy C++ code (some dated back to VC6, written 10 years ago), but I didn't understand the basic of C++ quite well, for example, how the header files work, and why c++ compiler requires the forward declarations,as well as the extern keyword. So I decided to find an online tutorial to learn some basics of C++, and this is what i found, learnCPP.com!
The tutorial is very well-written, in plain, comprehensible English, I hardly have to turn to the dictionary:-) (I am not an English speaker). Now I have been learning on this site for a couple of months, and I have to say everything I need to know to START programming in C++ can be found in this tutorial.
Admittedly this tutorial is not "an encyclopedia for the basic of C++", it does not include a dedicated chapter on unicode, or another chapter on the crt... but this tutorial is not meant to cover these topics, otherwise there will be much much more chapters in this tutorial.
Try and enjoy!
Learning by doing was the only thing which helped me to understand it. For example, if you want to learn templates and operator overloading, writing your own vector class which uses templates for the datatype of the elements and the length and operator overloading for all the operations as well as assignment will be an lengthy exercise which requires quite some nerves at first ;) But you will realize that you learnt how C++ actually works.
While I advice to write some small stuff as the example illustrated above, following the tutorial to learn the syntax and a the very basics probably isn't bad for a start.

What technique would you recommend when reviewing C++ for an interview? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I've got about 2/3 years C++ experience but I've spent most of my career doing Java. I'm about to go for an interview for a C++ programming role and I've been thinking about the best way to brush up my C++ to make sure I don't get caught out by any awkward questions. What would you recommend?
Effective C++ by Scott Meyers
If you have enough time try to write an application using C++ - go over the basics so when you'll be asked to show coding skills you'll be able to write code fluently.
I've noticed that during C++ centric interviews it is common practice to ask question about how it works:
How virtual methods are implemented?
What happens when you call new - how memory is allocated?
What is the difference between struct and class?
Why should you mark your class d'tor as virtual?
I guess a good way to learn all those is to read a good C++ book - if you have the stomach for it you can read Stroustrup book - but there bound to be other books just as good (with less pages in them).
Have a look at the C++ Style and Technique FAQ
As an interviewee, I depend on experience. As an interviewer, my favourite (and often only) C++ interview question is "Tell me about the copy constructor". It's amazing how many avenues this opens up, and how few people are aware of them - it can make for a very short interview. If the interviewee gets past that, I then ask "Which are your favourite C++ books, and why?"
Know the language. You can try to predict what questions they'll ask, but C++ can mean a lot of different things depending on who you ask. To some people, it's a clumsier Java, and all the questions will be about dynamic memory allocation, virtual functions and inheritance. To others, it's all about RAII, and avoiding memory management.
Some think the STL is the most important to ask questions about and some might want to dig in to your knowledge of some of the subtler aspects of the language (ranging from the copy constructor that Neil mentioned in his answer, to common cases of undefined behavior, or exception safety)
It's a big, complex language, and people can ask a lot of different questions about it. Unless you have some idea what areas they're likely to focus on, you're not likely to achieve much with last-minute brushing up.
Go through the questions on SO with
C++, OOP tags.
C++ FAQ
Must have C++ books for every advanced programmer:
Herb Sutter Exceptional C++: 47 Engineering Puzzles, Programming Problems, and Solutions
Herb Sutter More Exceptional C++: 40 New Engineering Puzzles, Programming Problems, and Solutions
Herb Sutter Exceptional C++ Style: 40 New Engineering Puzzles, Programming Problems, and Solutions
A.Alexandrescu and Herb Sutter C++ Coding Standards: 101 Rules, Guidelines, and Best Practices
Scott Meyers Effective C++: 55 Specific Ways to Improve Your Programs and Designs
Scott Meyers More Effective C++: 35 New Ways to Improve Your Programs and Designs
Scott Meyers Effective STL: 50 Specific Ways to Improve Your Use of the Standard Template Library
It depends: I went for a job with a certain large games company and 90% of the questions were graphics and micro-optimisation questions (this was for a C# testing role, stupidest test of my life!).
However, if you're going for a normal desktop-app role, you'll probably get asked about UIs, or if you're going for some sort of embedded computing role you'll likely be asked about optimisation and memory management.
In any case, I'd brush up on your BOOST, as an example of a good library, and your pointer knowledge.
I would just review the basics of the language: make sure you remember how to make classes, know when to pass it via reference and when to pass in via pointer, and why you'd want to do that vs pass by value. Why you'd want a virtual method, and what are the reasons one uses the C++ style casts vs the C style casts, when you'll need a copy constructor, things like that
I'd imagine what would help is remembering a war story or two about C++: ("man, const correctness is hard!", "so I once got into a fight with a coworker/teacher about this finer point of C++, and I learned that.."
If the job is for an entry level C++ job (which it should be with your limited C++ experience), I'd imagine that would be fine and that you'll (hopefully) not get cast too deep without a paddle/senior engineer to guide you.
"write a function that counts the number of 'on' bits in a byte"
that never gets old...
I saw a cool bitwise way of doing it once that could count all the on bits in a 32 bit DWORD in like 4 or 5 operations!
If I were an interviewer in this day and age I'd ask "what do you know about lock free codeing?"

What C++ tutorial would you recommend for an experienced programmer that has some patchy knowledge about the language? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
In my early days of programming, before I started working professionally, I wrote a fair share of trinket/exercise apps in C++ and felt fairly confident that I know the language. Then, as opportunity came, I went to do real work and left the C/C++ world. For the past 5 years I've written tons of code in C# and have had scarcely any encounters with the C/C++ languages. Now, after spending some time on SO and teh interwebs, I see that what I thought I know as "C++" is actually a mix between C and C++, with large gaps in my knowledge about the more intricate workings of the language. At the same time I also realize that I am intrigued by the language and would like to learn it more.
Googling for "C++ tutorials" reveals a wealth of tutorials, but they are all aimed at complete beginners, spending a lot of time explaining basics that I'm already familiar with. I don't expect that there will be any tutorials made exactly for me, but are there some that have at least been written with an experienced programmer in mind, not spending a lot of time on trivial things, and discussing the finer points of the language and compilers?
C++ is too complex to be learned through tutorials, you could only scratch the surface that way. Especially the advanced usage of the STL (and templates in general) is usually beyond the scope of online tutorials.
Therefore, I would recommend books: Stroustrup's "The C++ Programming Language", and Scott Meyer's "Effective C++", "More effective C++" and "Effective STL".
You can skip the first few chapters of Stroustrup if you feel confident you know that part already, but it's the best book for going into the details of the language. There should be a law for every aspiring C++ programmer to read at least the first two of Meyer's books I mentioned.
Once you're through with that, check out "Modern C++ Design" by Andrei Alexandrescu for a real eye-opener for what templates can be used for.
Update: In reaction to a downvote eight years later (...), be aware of The Definite C++ Books List. My personal recommendations above hold true, but that list is community-driven.
C++ is a very old language so there are lots of good books available. I would recommend to read those books, rather than searching sites and blogs. My personal experience says in harder to find lot of good articles at one place, by most of the good articles are already in books.
Regarding sites:
Dr. Dobb's site and journal have lots of good articles.
Books:
Effective C++
Exceptional C++
C++ Object Model
Bjarne Stroustrup
Beyond the C++ Standard Library
I suggest, though rather as supplement, the C++ FAQ Lite. It has information ranging from basic things to really obscure C++ features and many tips to write good C++ and helped me more than once when some stupid template thing or whatever wouldn't do what I expect.
1.C++ Object model is nice book for professionals.
2.Design and evolution of C++ by bjarne stroustrup give you in-depth insight.
3.Scott Meyers' Effective C++ series is also nice one.
You've gotten a number of good recommendations, but none seems to have included the one that was really written to fit your situation. Accelerated C++ was written for people who already know the basics of programming, and just want to learn how to program in C++.
Workings of the language? What areas exactly do you think are worth improving? I have a slight trouble extracting it from your question.
One book that i always keep on my table and peek into frequently is C++ Primer by Lippman et al, 4th ed., ISBN 0-201-72148-1. This is not a tutorial, this is a reference. Whenever you have a question about the language itself, this is where you can find a short and precise answer.
If you want specifically a tutorial which aims at experienced C programmers, see Bruce Eckel's Thinking in C++. Available as free download on author's site and also printed through Prentice Hall.
At some point you will have learnt a great many things which you CAN do, from then on, you should learn what NOT to do. This is a long and painful part, and i don't have a precise recipy, but accept my sympathies. The deeper you get involved into complex stuff the more likely is it to bite you at some point due to conflicts between language features. I suggest taking a look at Imperfect C++ by Matthew Wilson, C++ Coding Standards by Sutter and Alexandrescu.
You probably want to skip the stuff you already know and move on to harder more fun stuff. I assume you already know a lot about the language and it's syntax, methods, classes, etc.
Where to start? Well, there are very good books and papers on the language. I can recommend many books on the language but you can probably find them using the stackoverflow search.
I can only tell you what you already know. You wont find a book that covers it all. You will have to browse through many books in order to get what you desire. Take a randomly recommended book, browse through it skip the stuff you know and try to fit it all together. Try to make something out of the fresh knowledge by writing some code to understand it better. Do it until you understand it fully.
Here is a brief tutorial for advanced C programmers to refresh your memory on the language.
Essential C++ by Lippman is a small but great book.

Learn C++ to understand examples in book fast, know C and Java already [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I need to read "A Practical Introduction to Data Structures and Algorithm Analysis" by Shaffer for class but the code examples in the book are all in C++ which I do not know. I know C and Java already and was wondering if you knew any resources that helped learn enough C++ to understand these examples fast if you already know another language. Thanks!
Another free textbook is The C++ Annotations by Frank B. Brokken. You can browse it online, or you can download the pdf version.
A quote from the first page:
This document is intended for
knowledgeable users of C (or any other
language using a C-like grammar, like
Perl or Java) who would like to know
more about, or make the transition to,
C++. This document is the main
textbook for Frank's C++ programming
courses, which are yearly organized at
the University of Groningen
What I like about "The C++ Annotations" is that is being kept uptodate, version 8.0.0 has
added C++0x chapters.
Yes, (the first edition of) Thinking in C++ taught me how to read C++ syntax; it was designed for C programmers and each chapter built incrementally onto my existing knowledge of C, which I found helpful (and it's now available in print or as a download). Many people recommend it.
I'm not familiar with the book, but any good Algorithms and Data Structure book should be understandable to anyone with programming experience, weather they understand the language the examples are in or not.
Especially, in your case where you already know Java and C, I can't see that you will have any problems following the algorithms just because they are written in C++
This is quite a textbook (and quite expensive, so see if your library has it), but I would recommend the man's book itself, the C++ Programming Language linky. I used it to enhance, rather than create, my understanding of C++, but I used it in the form of a dictionary, and it seemed to work out well. It is written for people comfortable with programming, and you've gotten the pointers AND the OO stuff down, so it may mesh well.
For example... Chapter 2, a Tour of C++ (as I have it open in my lap now), talks about a large number of things, many of which compare themselves to the "C" way of doing things. The things are not new to a Java programmer, but different syntax, etc. Basically, if you want to learn about C++ iterators, look up the iterators chapter, etc.
I think you'll do ok without necessarily needing a book, but C++ has ridiculously tricky syntax, (try figuring out how to assign a constant field in an object instance using the constructor, for example) and I found the book to be quite illuminating. Thankfully, there's a pretty nifty index including operators, which is quite helpful.
Lastly, if you want to be a guru (which I certainly am not), there are discussions about everything from "Exception-Safe implementation techniques" (Appendix E.3) to philosophy of developing large software projects.
So I've given you quite the advertisement (I've never met the guy, honest), but I've found the book to be quite useful.
See the following previous questions for online C++ learning resources:
https://stackoverflow.com/questions/45175/resources-online-to-learn-c
https://stackoverflow.com/questions/909323/what-are-good-online-resources-or-tutorials-to-learn-c
I'd recommend taking a look through C++ Primer Plus (5th Edition). What you probably need to get your head around is the syntax for:
the type system
templates
operator overloading
The basic syntax of C++ is usually fairly easy to get a hold of, however, C++ is a complex multi-paradigm language, which requires some serious study to use it effectively.
C++ Primer Plus (5th Edition) http://ecx.images-amazon.com/images/I/41YAKQF6BML._SL160_.jpg
I'm surprised no one has yet mentioned Accelerated C++. It's not based as much on your existing knowledge of C (or Java), but it will teach you the language as it stands alone.
I found 'C++' by Till Jeske, 2002, ISBN 0-201-75879-2 very good. It is not a pet killer, only 1.25 thick, and quite well written - concise and to the point. I knew some C++ before but Jeske's book really helped me.

Why people think that the only man who created C++ was Bjarne Stroustrup? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I am currently reading Stroustrup's book "Design and Evolution of C++" and it turns out that he was not the one who developed C++. When I hear someone saying "Bjarne Stroustrup developed C++ blah-blah-blah", I always feel it is very unfair to these guys who worked with BS - I mean Jonathan Shopiro, Andrew Koenig, Stan Lippman, Stefan Dewhurst and others. Why is it that way? Even wikipedia does not mention his team - only him What it that about?
EDIT:
When people say C#, they did not mean Anders Hejlsberg ONLY, there were a development team working on both exactly C# and .NET Framework. May be it`s because C++ does not belong to any software-giant company, as Java to Oracle or C# to Microsoft?
C++ has gone through two major stages of its evolution.
The early days were Bjarne Stroustrup making a language. He obviously borrowed ideas from others, and solicited feedback from several clever language designers, and no doubt had a small team working under him, but the language was fundamentally his baby.
In those days, I don't really have a problem with saying that Stroustrup designed the language. Obviously he didn't do it in a vacuum, he got a good deal of help from others, but that's just it. They helped him design his language. They didn't take ownership of it.
The second phase is where it's at now: An ISO standard. These are maintained by committees, and in the C++ committee, Stroustrup is just one out of many participating members. His words might still carry a bit more weight because of his history with the language, but fundamentally, he no longer has any kind of special status. He's just a contributor, like all the others in the committee.
The moment the language was standardized, it ceased to be "his" language. After that, he, and many others just helped the ISO maintain and evolve the language.
At least that's how I see it.
One reason why people might think Mr Stroustrup did it is that he says so himself, on the web:
I (Bjarne Stroustrup) am the designer
and original implementor of C++.
I haven't read the book you mention; can you add quotes to the question that show how the evolution of the language and who did what is explained, therein? It seems weird for Mr Stroustrup to be claiming one thing on the web, very much in public, and another in a book.
That's usual. Nobel prizes are also given to one or several people and noone mentions numerous people who devoted their time to the research process that actually made the achievement possible.
One reason for that is it's easier to remember one name than two dozens or hundreds.
It's kinda the same thing as with PHP and Rasmus Lerdorf. He fathered the idea but later on other people joined in.
Thats because people think in persons, not in teams or companies, whatever.
I think the human brain associates single things with single persons. Thats how we work internally. Although we try to be rational and logical we cannot deny our nature.
Its the same reason why a state has one single president, although decisions are made by lots of other politicians.
That you feel it is unfair is an irrational response. At the risk of upsetting you even more, I have no problem stipulating that Linus Torvalds created Linux or that Jim Delligatti invented the Big Mac. The reason I can do that is I do not suffer from the delusion that most of not all products or inventions are the result of a synthesis of ideas and involve myriad anonymous sources before coming to fruition.