Best way to (re?)learn c++

This is a discussion on Best way to (re?)learn c++ within the C++ Programming forums, part of the General Programming Boards category; G'day all, Just a bit of background. I have been programming in Qbasic for about 12 yrs, and then through ...

  1. #1
    Registered User
    Join Date
    Oct 2004
    Posts
    25

    Best way to (re?)learn c++

    G'day all,

    Just a bit of background. I have been programming in Qbasic for about 12 yrs, and then through uni (about 8 yrs ago) did a semester of introductions to C (although had also self-taught some C anyway), then spent most of it in Java.

    My Java skills are pretty good - to me the language seems far more elegant than C++. I realise it comes at a price, but the errors I get in Java are childs play compared to the mess I can make of a C++ program :S

    Anyway, while I was learning Java I was also teaching myself some C++. However, my C++ has always been at the level of "learn it as I need it", and tends to be "I know I can do something in Java, so I should be able to do it in C++". I think this leads to problems, especially where Java does some things differently to C++ (eg garbage collection / dynamic memory, passing parameters to functions). I think I'm missing a lot of the syntax / underlying knowledge of C++ - and instead learning it as if it is the bastard son of C and Java, and learning it in an ad-hoc way.

    What would be a good way of filling in these gaps? I'm pretty sure beginner level stuff is well beneath me - the sort that will spend the first 3 chapters writing "Hello World" then going into if statements. The following is a list of my weaknesses:
    - Objects - syntax, passing them around, using them, inheritance etc. Again, I know conceptually how they work, they just don't seem to work with me behind the keyboard.
    - STL libraries - starting to get into these, but again ad-hoc and it seems to take me hours to do the simplest things.
    - Memory management - again I know enough to know I don't really get this completely.

    Heh, even this list is starting to sound like "stuff I do in Java but not in C" :P

    I'm sure there's more, but any advice on a rigorous way to learn this stuff? It's getting frustrating spending hours doing simple things, then many hours more fixing them to do it right. I'm not sure searching for ad-hoc internet tutorials / examples is the most efficient way to keep doing it.

    *Disclaimer: I did not say Java is better than C++. I do however find it a lot more elegant to read / write - no stuffing around with pointers, memory management etc - it all just works. I know this comes at a tradeoff, C++ giving you lower level access and higher speed. Just trying to avert an accidental flamewar :P

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,317
    I think the best way would be to learn C++ from scratch the "C++ way". You'll breeze through the beginning sections but gain a better understanding for the C++ mindset. I think buying and working through Accelerated C++ by Koenig and Moo would be perfect for this situation.

  3. #3
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Swordsalot View Post
    What would be a good way of filling in these gaps?

    I'm pretty sure beginner level stuff is well beneath me - the sort that will spend the first 3 chapters writing "Hello World" then going into if statements.
    ...
    I'm sure there's more, but any advice on a rigorous way to learn this stuff? It's getting frustrating spending hours doing simple things, then many hours more fixing them to do it right. I'm not sure searching for ad-hoc internet tutorials / examples is the most efficient way to keep doing it.
    I'm presently nearing the end of Thinking in C++ Volume 1 and of course still have Volume 2 to go... Like you I used to think "the beginner stuff is below me" because I have a solid background in Pascal and am pretty settled in with C, and that somehow qualified me to skip chapters. But, you know what... it also disqualified me from learning the language.

    The problem with mid to high level languages like QBasic or Java (and Pascal to a lesser degree) is that a lot of stuff you *should* know about is hidden from you. The tradeoff is that you get to be a less precise programmer but still crank out code on time... In my thinking, that's not a great tradeoff once you realize what the "lower level" languages like C can actually do... I can pretty much guarantee nobody's going to write an Operating System in Java... but there are several written in C.

    What I learned was to allow myself to be humbled by it. Really... you should never be afraid to flip that all important switch from "Teacher" to "Student" on a split-second's notice. If there's no pride involved there's no big blow when that "Ok I need help" moment comes... and it will come.
    (You can see mine right in the threads of this forum...)

    Yes, as already advised, you should learn C++ as a separate experience. I promise you it is just that... Do the "Hello World" and other kiddie exercises... I was pleasantly surprised at how good a review that was...

    Bruce Eckel's MindView, Inc: Thinking in C++ 2nd Edition by Bruce Eckel

    Accelerated C++

  4. #4
    Registered User
    Join Date
    Oct 2004
    Posts
    25
    Thanks.

    Just want to say, I acknowledge that any worthwhile book covering the things I wanted will include plenty of rehashing of the things I already know (I'm not going to find a useful book that covers all my holes without hitting anything I know). Just wanting to say - I didn't want the ones where the whole thing is a rehash of "if", input / output, loops etc. I very nearly dropped out of my Comp Science degree when I realised the first year would be entirely this basic stuff which I'd done plenty before.

    Don't mean to say I'm too good to have a book that has a couple chapters rehashing the basics. Just as long as it does other stuff :P

    And considering I'm wanting to do this after about 12 hrs of trying to work out where I lost a pointer in my code (and still not finding it), I KNOW my code style must be wrong. Really the reason I need to work out what all my little commands are doing.

    Accelerated C++ sounds perfect, but I'm cheap, and like eBooks, so will read through "Thinking in C++" first. The PReface at least makes it sound like it's aimed at people in my position - some scattershot experience without formal learning.

    Anyone know where I can get a compiler that I can run off a thumb drive (no install), or perhaps an online one? Want to try to go through some of these exercises at work.

  5. #5
    -bleh-
    Join Date
    Aug 2010
    Location
    somewhere in this universe
    Posts
    454
    Quote Originally Posted by Swordsalot View Post
    Thanks.

    Just want to say, I acknowledge that any worthwhile book covering the things I wanted will include plenty of rehashing of the things I already know (I'm not going to find a useful book that covers all my holes without hitting anything I know). Just wanting to say - I didn't want the ones where the whole thing is a rehash of "if", input / output, loops etc. I very nearly dropped out of my Comp Science degree when I realised the first year would be entirely this basic stuff which I'd done plenty before.

    Don't mean to say I'm too good to have a book that has a couple chapters rehashing the basics. Just as long as it does other stuff :P

    And considering I'm wanting to do this after about 12 hrs of trying to work out where I lost a pointer in my code (and still not finding it), I KNOW my code style must be wrong. Really the reason I need to work out what all my little commands are doing.

    Accelerated C++ sounds perfect, but I'm cheap, and like eBooks, so will read through "Thinking in C++" first. The PReface at least makes it sound like it's aimed at people in my position - some scattershot experience without formal learning.

    Anyone know where I can get a compiler that I can run off a thumb drive (no install), or perhaps an online one? Want to try to go through some of these exercises at work.
    here's an online one that people seem to use alot: codepad
    "All that we see or seem
    Is but a dream within a dream." - Poe

  6. #6
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Swordsalot View Post
    Anyone know where I can get a compiler that I can run off a thumb drive (no install), or perhaps an online one? Want to try to go through some of these exercises at work.
    First, one of the reasons I suggested thinking C++ is that it really is about C++ ... there's a chapter in there on C, and it's written for someone who simply needs a review... He really rolled through it quite quickly but still managed to show me a thing or two...

    Compiler wise... you should look at code:blocks which comes with MinGW which compiles either C or C++ code, it's free, comes with all libraries and headers... Code::Blocks

    If you copy the MinGW compiler out of the IDE it will run on a flash drive from the command line... but you'll have to do some setting up to get it to work.... (Yes, you can download MinGW or GCC separately, but my way you get a real nice IDE as well)
    Last edited by CommonTater; 01-18-2011 at 05:57 AM.

  7. #7
    Registered User
    Join Date
    May 2009
    Posts
    2,569
    Quote Originally Posted by CommonTater View Post
    Compiler wise... you should look at code:blocks which comes with MinGW which compiles either C or C++ code, it's free, comes with all libraries and headers... Code::Blocks
    The above is false, Code::Blocks optionally comes with MinGW-Like GCC for Windows; this includes the normal libraries for MinGW GCC and maybe a few more. It does NOT come with all the libraries that can be used with MinGW GCC.

    Tim S.

  8. #8
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by stahta01 View Post
    The above is false, Code::Blocks optionally comes with MinGW-Like GCC for Windows; this includes the normal libraries for MinGW GCC and maybe a few more. It does NOT come with all the libraries that can be used with MinGW GCC.

    Tim S.
    Exactly how picky do you intend to be?

  9. #9
    Registered User
    Join Date
    May 2009
    Posts
    2,569
    Quote Originally Posted by CommonTater View Post
    Exactly how picky do you intend to be?
    When you answer about 50 idiots questions with you need to verify the library is installed and they said "does it not have all the library including MS SDK in it?"; a person get real tired of it.

    Tim S.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21