• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Beginning C++

YoungGun21

Platinum Member
I'm starting to learn C++ and I was wondering if anybody had any suggestions for me on what programs I should make?

I'm about done with my first one (actually, I'm stuck on it, but rather than post for help I'd like to figure it out myself). My first project obtained a range of integers from the user and then outputted all of the prime numbers in the range. I didn't write the piece that found the prime numbers, I am just adapting one that found all primes from 2 to N. Changing the range has proved trickier than I thought.
 
Write up some data structures: linked lists, binary trees, red black trees, queues, deques, stacks, heaps, hash tables, etc.
 
Build a blackjack game. This will get you used to some of the concepts and have some fun while at it.
 
Make all the programs in the book. Start with the simple ones and do every single example. It helps if you start simple and then build up slowly. By doing the example programs it helps you to get the hang of it. After a while, you start to realize what is going on. Even if you dont understand what is going on you start to see how it works by doing all the programs in your book.

Card Games - Shuffle or randomize and the put in order using a bubble sort. If you refresh the screen between each sub-step you can see the cards moving around. Might have to slow down the action with a rude counter so you can see it.

Mine Sweeper Game -We did this mine sweeper game where we used on array and then you had to have a choice between 3 different sizes.

We also did a car game where you built both a manual and auto transmission cares showing one bar for the tach and one bar for the speed it was a pretty easy project but if you over torqued i.e. red-lined the car would blow up. This envolved a class for the car and a subclass for auto and manual transmission. You could also add sound and make it vary based on what gear you were in and the RPM readings. This was not very visual and it was like 15 years ago.

Newer books should have more visual stuff in it.
 
Last edited:
learn c first

Meh. -1.

Depending on what it is you're trying to do, you might at some point want to learn C, but I certainly wouldn't call it a precursor to learning C++.

Just because us older folks learned that way doesn't mean it's the right way. I started with BASIC and Pascal, but I certainly wouldn't suggest he start there. If he's bright enough to start with C++ then there's no reason to start with C, since as far as difficulty goes, it's 6 up, a half dozen down either way you look at it. And if all he wants to do is learn some C++ for a particular project, then he'll certainly not want to confuse himself with such a similar language.

An excellent starting book is C++ Primer by Lippmann, LaJoie and Moo. After you get some of that under your belt, I've had good success with Accelerated C++ by Koenig and Moo as a second text (for someone that's *extremely* bright, or with some programming experience in another modern language, Accelerated C++ could be a first text, augmented with tutelage from Mr. Google).

That said, if the OP is looking to take up programming for a living, I'd probably suggest against starting with C++ and suggest either Python or Ruby, since their interactive nature shortens feedback loops and helps out with "beginner frustration". For Python I've heard recommendations from people I respect for Beginning Python by Hetland and Practical Programming by Campbell, Gries, Montojo and Wilson (sounds like a bloody law firm 🙂). When I learned Python I "jumped in the deep end" with Programming Python by Lutz, though these days I'd use that as a second text (makes a good reference, too) or for someone that's already got some experience with another language. For Ruby there's Learn to Program by Pine, which again, I've not used, but have heard good things about. After that would be Programming Ruby by Thomas, Fowler and Hunt.

As far as websites go, I thought Project Euler looked cool (haven't tried it yet, saved for later) and I've done some of the challenges on this site: http://www.programming-challenges.com/pg.php?page=index and found them pretty neat. Personally, my "go to" project for learning a new language is Tic Tac Toe, since the algorithms are nice and simple so I don't obscure the facets of the new language with learning some wonky new algos with which I'm not familiar.

Ok, done with the wall of text. 🙂 Good luck, and keep us posted.
 
Heh, I never said I didn't like C++ (presuming you're talking to me) but for someone with zero programming experience (which from the OPs post is what it sounded like to *me*...I could, of course, be wrong) I'm not convinced it's the best language to use to start with if ones goal is to take up programming as a profession.

Like I mentioned, if he's just using it for a specific project, that's another story, and I think I gave some good (though by no means exhaustive) examples of places to go in either case.
 
I do have pretty much no programming experience (I haven't taken any CS classes yet, I'm just doing this because I find it interesting). I will have to learn C++ eventually, like within the next 3 or 4 semesters, but I'm not in a huge hurry. I had heard it wasn't a bad language to start with, so I thought I'd start there. I haven't really had too much trouble learning it with the free tutorials that can be had online. I think I'm getting a solid grasp with it so far. Perhaps I'll order a book in a few weeks to further my knowledge.
 
I do have pretty much no programming experience (I haven't taken any CS classes yet, I'm just doing this because I find it interesting). I will have to learn C++ eventually, like within the next 3 or 4 semesters, but I'm not in a huge hurry. I had heard it wasn't a bad language to start with, so I thought I'd start there. I haven't really had too much trouble learning it with the free tutorials that can be had online. I think I'm getting a solid grasp with it so far. Perhaps I'll order a book in a few weeks to further my knowledge.

People shit on C++ for being complicated and having a difficult syntax, but it was the first language in learned in high school, and I'm no programming genius by a long shot. I still prefer it for non-GUI applications, and C# for GUI stuff. There is a ton of documentation for it and it's portable. But in the end you should be able to learn any language fairly easily once you get the concepts down, which is why it's being shunned somewhat for beginners.

You should always pick the language to match the application, and after that comes preference.
 
i'm just reading/following tutorials, etc on cplusplus.com at the moment

aside from matlab (which isn't really programming to me...atleast the way i use it lol), and a python class i took 4 years ago (extra lol), i find that the tutorial is pretty straight forward and easy. still not exactly sure what the big deal is about defining terms using pointers (ie: *bla = bla2, where bla = &cat) instead of just defining it directly like cat=bla2...but i'm sure that in good time it will be clear 😉

http://cplusplus.com/doc/tutorial
 
Back
Top