C++ tutorials for C programmers?

Discussion in 'C++' started by army1987, Feb 14, 2012.

  1. army1987

    army1987 Guest

    What free online C++ tutorial would you recommend to someone who already
    knows C? In the FAQ I've found a list of C features I had better unlearn
    (but without a pointer to a longer discussion of the issue), and a couple
    of links to C++ tutorials both of which are broken. I'd just google for
    "C++ tutorial" but I'd have no way to know which tutorials are best.



    --
    Vuolsi così colà dove si puote
    ciò che si vuole, e più non dimandare.
    [ T H I S S P A C E I S F O R R E N T ]
    <http://xkcd.com/397/>
    army1987, Feb 14, 2012
    #1
    1. Advertising

  2. On 14.02.2012 20:55, army1987 wrote:
    > What free online C++ tutorial would you recommend to someone who already
    > knows C? In the FAQ I've found a list of C features I had better unlearn
    > (but without a pointer to a longer discussion of the issue), and a couple
    > of links to C++ tutorials both of which are broken. I'd just google for
    > "C++ tutorial" but I'd have no way to know which tutorials are best.


    The borked links in the C++ FAQ are to a tutorial that I wrote but
    that's off the net now.

    At the time I wrote it there were no even halfway decent C++ tutorials
    on the net. They were all full of technical errors. And that was even a
    FAQ item, in the FAQ for the learn-C-and-C++ Usenet group.

    However, now there are tutorials and on-line books that, while not
    perfect, are not full of errors, e.g. as listed at


    http://stackoverflow.com/questions/909323/what-are-good-online-resources-or-tutorials-to-learn-c

    and in particular for a concise tutorial,

    http://www.cplusplus.com/doc/tutorial/

    which *almost* appeared in the SO answers.

    Cheers & hth.,

    - Alf
    Alf P. Steinbach, Feb 14, 2012
    #2
    1. Advertising

  3. army1987

    army1987 Guest

    On Tue, 14 Feb 2012 21:08:25 +0100, Alf P. Steinbach wrote:

    [...]

    > http://www.cplusplus.com/doc/tutorial/


    Thank you, I'll try this one.



    --
    Vuolsi così colà dove si puote
    ciò che si vuole, e più non dimandare.
    [ T H I S S P A C E I S F O R R E N T ]
    <http://xkcd.com/397/>
    army1987, Feb 14, 2012
    #3
  4. army1987

    Jorgen Grahn Guest

    On Tue, 2012-02-14, army1987 wrote:
    > What free online C++ tutorial would you recommend to someone who already
    > knows C? In the FAQ I've found a list of C features I had better unlearn
    > (but without a pointer to a longer discussion of the issue),


    Where's that list? There is one in [28.2] "Should I learn C before I
    learn OO/C++?", but it has motivations for all of them. (Not that I
    think that list is exhaustive or anything.)

    > and a couple
    > of links to C++ tutorials both of which are broken. I'd just google for
    > "C++ tutorial" but I'd have no way to know which tutorials are best.


    I recommend handling it as if you didn't know C, but was an
    experienced programmer. I.e. buy real books and use them in your
    studies. Stroustrup's The C++ Programming Language is one book for
    that audience.

    /Jorgen

    --
    // Jorgen Grahn <grahn@ Oo o. . .
    \X/ snipabacken.se> O o .
    Jorgen Grahn, Feb 14, 2012
    #4
  5. army1987

    Army1987 Guest

    On 14 Feb, 23:33, Jorgen Grahn <> wrote:
    > Where's that list? There is one in [28.2] "Should I learn C before I
    > learn OO/C++?", but it has motivations for all of them. (Not that I
    > think that list is exhaustive or anything.)


    Yeah, I meant that one. I hadn't followed the links (what the hell was
    I thinking of?).

    > I recommend handling it as if you didn't know C, but was an
    > experienced programmer.  I.e. buy real books and use them in your
    > studies. Stroustrup's The C++ Programming Language is one book for
    > that audience.


    That'd be overkill. I needn't write any programs from the grounds up,
    only adapt some existing simulation code to a slightly different
    problem.
    Army1987, Feb 16, 2012
    #5
  6. On Feb 16, 1:31 pm, Army1987 <> wrote:
    > On 14 Feb, 23:33, Jorgen Grahn <> wrote:
    >
    > > Where's that list? There is one in [28.2] "Should I learn C before I
    > > learn OO/C++?", but it has motivations for all of them. (Not that I
    > > think that list is exhaustive or anything.)

    >
    > Yeah, I meant that one. I hadn't followed the links (what the hell was
    > I thinking of?).
    >
    > > I recommend handling it as if you didn't know C, but was an
    > > experienced programmer.  I.e. buy real books and use them in your
    > > studies. Stroustrup's The C++ Programming Language is one book for
    > > that audience.

    >
    > That'd be overkill. I needn't write any programs from the grounds up,
    > only adapt some existing simulation code to a slightly different
    > problem.


    there is a lot of difference between idiomatic C++ and idiomatic C. If
    you're going to do maintenance ona C++ code base i think you're going
    to have to learn C++
    Nick Keighley, Feb 16, 2012
    #6
  7. army1987

    none Guest

    In article <jhee88$qf2$>,
    army1987 <> wrote:
    >What free online C++ tutorial would you recommend to someone who already
    >knows C? In the FAQ I've found a list of C features I had better unlearn
    >(but without a pointer to a longer discussion of the issue), and a couple
    >of links to C++ tutorials both of which are broken. I'd just google for
    >"C++ tutorial" but I'd have no way to know which tutorials are best.


    Some other peoples have already pointed to some online resource that
    might be decent and useful:

    I'll throw an alternative view here however:
    - Do you value learning C++?
    - Do you value your time?

    If you answer yes to both of the above, then I'd suggest you do not
    try to learn something difficult like C++ using second class teaching
    tools just because they are free. You will likely end up learning
    badly or would need to spend a lot more time in order to reach the same
    level that you would gain with top class learning tools.

    Note: I do not mean that some free teaching resource might not be
    good. Just that by limiting yourself to "free online", you might not
    have to get money out of your wallet but you may still end up paying
    for it in a different way.

    Yannick
    none, Feb 16, 2012
    #7
  8. army1987

    Silent Stone Guest

    On Feb 16, 1:03 pm, yatremblay@bel1lin202.(none) (Yannick Tremblay)
    wrote:
    > Note: I do not mean that some free teaching resource might not be
    > good.  Just that by limiting yourself to "free online", you might not
    > have to get money out of your wallet but you may still end up paying
    > for it in a different way.
    >
    > Yannick



    On this subject, what might be some good books for someone with some
    programming experience to properly learn C++ with? I presume
    Stroustrup's book is _The Tome_ of this language? Would someone be
    better off chosing that over Accelerated C++, or Lippman's C++ Primer?

    Thanks.

    -John
    Silent Stone, Feb 16, 2012
    #8
  9. Yannick Tremblay <yatremblay@bel1lin202.(none)> wrote:
    > If you answer yes to both of the above, then I'd suggest you do not
    > try to learn something difficult like C++ using second class teaching
    > tools just because they are free. You will likely end up learning
    > badly or would need to spend a lot more time in order to reach the same
    > level that you would gain with top class learning tools.


    Recommending that one should use competent sources to learn the
    language is easy. Recommending such a source is more difficult.
    Any suggestions?
    Juha Nieminen, Feb 16, 2012
    #9
  10. army1987

    Ebenezer Guest

    On Feb 16, 4:09 pm, Juha Nieminen <> wrote:
    > Yannick Tremblay <yatremblay@bel1lin202.(none)> wrote:
    > > If you answer yes to both of the above, then I'd suggest you do not
    > > try to learn something difficult like C++ using second class teaching
    > > tools just because they are free.  You will likely end up learning
    > > badly or would need to spend a lot more time in order to reach the same
    > > level that you would gain with top class learning tools.

    >
    >   Recommending that one should use competent sources to learn the
    > language is easy. Recommending such a source is more difficult.
    > Any suggestions?



    I've noticed the number of people viewing C++ and Beyond
    videos and the recent Going Native videos is pretty high.
    I agreed with Bjarne scolding some of the other panel
    members for talking at length about shared_ptr. Bjarne
    said he thinks of shared_ptr as something to be used "last".

    The code on my website is increasingly robust over time --
    http://webEbenezer.net .

    Brian
    Ebenezer, Feb 17, 2012
    #10
  11. Ebenezer <> wrote:
    > I agreed with Bjarne scolding some of the other panel
    > members for talking at length about shared_ptr. Bjarne
    > said he thinks of shared_ptr as something to be used "last".


    That's also my experience. I program quite a lot in C++ as my payjob,
    and *extremely* seldom do I have the need for shared_ptr or anything
    equivalent.

    If you have the need for shared_ptr that means you are allocating
    objects individually with 'new'. Of course it may depend on the type
    of application, but in practice I have noticed that needing to do so
    is quite rare. In the vast majority of cases handling objects by value
    is enough. If dynamic memory allocation is needed, it's usually needed
    en masse, in which case you usually don't allocate the objects
    individually with explicit 'new's, but instead you use one of the
    standard library containers.

    Perhaps GUI programming is something where allocating individual,
    polymorphic objects is needed. OTOH in many cases you will usually be
    using a GUI library which in itself provides the means to manage those
    allocated objects...

    One of the problems with shared_ptr is that it's very large in size,
    compared to what it's "emulating", ie. pointers. If you create a shared_ptr
    and give it an allocated object, it will take typically as much memory
    as a dozen of pointers or so. Also, shared_ptr typically makes a memory
    allocation in itself, so the total amount of allocations has doubled.
    If you are allocating a couple of objects then that doesn't matter, but
    it might matter if you are allocating millions of them (in terms of both
    memory consumption and speed).
    Juha Nieminen, Feb 17, 2012
    #11
  12. On Feb 17, 7:16 am, Juha Nieminen <> wrote:
    > Ebenezer <> wrote:


    > > I agreed with Bjarne scolding some of the other panel
    > > members for talking at length about shared_ptr.  Bjarne
    > > said he thinks of shared_ptr as something to be used "last".

    >
    >   That's also my experience. I program quite a lot in C++ as my payjob,
    > and *extremely* seldom do I have the need for shared_ptr or anything
    > equivalent.
    >
    >   If you have the need for shared_ptr that means you are allocating
    > objects individually with 'new'. Of course it may depend on the type
    > of application, but in practice I have noticed that needing to do so
    > is quite rare. In the vast majority of cases handling objects by value
    > is enough. If dynamic memory allocation is needed, it's usually needed
    > en masse, in which case you usually don't allocate the objects
    > individually with explicit 'new's, but instead you use one of the
    > standard library containers.


    I may be missing something obvious, but aren't containers of pointers
    useful for polymorphic dispatch?

    std::vector<Shape*> picture;

    and if you don't want to use raw pointers don't you end up using
    shared_ptr?

    >   Perhaps GUI programming is something where allocating individual,
    > polymorphic objects is needed.


    don't lots of other sorts of programming use lots of polymorphic
    objects?

    > OTOH in many cases you will usually be
    > using a GUI library which in itself provides the means to manage those
    > allocated objects...


    your own application specific objects as well?

    >   One of the problems with shared_ptr is that it's very large in size,
    > compared to what it's "emulating", ie. pointers. If you create a shared_ptr
    > and give it an allocated object, it will take typically as much memory
    > as a dozen of pointers or so. Also, shared_ptr typically makes a memory
    > allocation in itself, so the total amount of allocations has doubled.
    > If you are allocating a couple of objects then that doesn't matter, but
    > it might matter if you are allocating millions of them (in terms of both
    > memory consumption and speed).
    Nick Keighley, Feb 17, 2012
    #12
  13. army1987

    none Guest

    In article <>,
    Silent Stone <> wrote:
    >On Feb 16, 1:03 pm, yatremblay@bel1lin202.(none) (Yannick Tremblay)
    >wrote:
    >> Note: I do not mean that some free teaching resource might not be
    >> good. Just that by limiting yourself to "free online", you might not
    >> have to get money out of your wallet but you may still end up paying
    >> for it in a different way.
    >>

    >
    >On this subject, what might be some good books for someone with some
    >programming experience to properly learn C++ with? I presume
    >Stroustrup's book is _The Tome_ of this language? Would someone be
    >better off chosing that over Accelerated C++, or Lippman's C++ Primer?


    IMO, for initial learning:

    Stroustrup, "The C++ Programming Language" is an excellent reference
    book. It clearly and precisely explains the language and it is a book
    I refer to regularly. For a professional C++ programmers, it may well
    be the most used book ever. However, it is not the best
    teaching/introduction book.

    Koenig, "Accelerated C++" is an excellent tutorial. I would strongly
    recommend it for learning C++. Its thickness (or relative lack of)
    means that there a chance that the reader actually go through the
    whole book rather than get bored by chapter 23, p654. OTOH, this is
    not a reference book.

    Lippman, "C++ Primer": Also an excellent learning book. Personally, I
    prefer Koenig, however, the additonal page count of C++ Primer allow
    it to go slower in places, be more explicit or have more examples and
    be a bit more reference-like. As a learning book, I'd say both are
    excellent and this is probably a personaly choice if you prefer more
    conscise books or more explicit one.

    Personally, I'd stay away from any book called "Teach yourself C++ in
    [1 hour|24 hours|1 week|...]" or "C++ for [dummy|idots|...]". Any one
    claiming to teach C++ in a few hours is lying and anyone claiming to
    teach complex stuff to idiots is also lying. :)


    Yannick
    none, Feb 17, 2012
    #13
  14. army1987

    none Guest

    In article <4f3d7ea4$0$2800$>,
    Juha Nieminen <> wrote:
    >Yannick Tremblay <yatremblay@bel1lin202.(none)> wrote:
    >> If you answer yes to both of the above, then I'd suggest you do not
    >> try to learn something difficult like C++ using second class teaching
    >> tools just because they are free. You will likely end up learning
    >> badly or would need to spend a lot more time in order to reach the same
    >> level that you would gain with top class learning tools.

    >
    > Recommending that one should use competent sources to learn the
    >language is easy. Recommending such a source is more difficult.
    >Any suggestions?


    Yes, see other post.

    I didn't include any book recommendation because I didn't want to
    confuse the point I was making. If I'd include some book name,
    peoples might diverge into ading their opinion of these books or
    recommending other books.

    It's like the classic TCO accounting: total cost of ownership is not
    only the purchase price of the item/tool/service.

    Similarly TCL: total cost of learning is not simply the purchase price
    of the tutorial text.

    In some circumstances, for some peoples, it might even be the paid-for
    courses with an actual teacher might be better value and more
    productive. In the OP case, probably not. But for a company or
    someone that need to learn quickly, maybe.

    Yannick
    none, Feb 17, 2012
    #14
  15. Nick Keighley <> wrote:
    > I may be missing something obvious, but aren't containers of pointers
    > useful for polymorphic dispatch?


    They are, *if* you need polymorphic dispatch. As said, in practice
    I have needed this very rarely. In the vast majority of cases handling
    objects by value has been enough.

    >>   Perhaps GUI programming is something where allocating individual,
    >> polymorphic objects is needed.

    >
    > don't lots of other sorts of programming use lots of polymorphic
    > objects?


    Like what, for example?

    GUI programming is the only type of *practical* situation where
    polymorphic objects are the best and most natural solution, at least
    in my own line of work. (It might be different for other types of
    programming tasks.)
    Juha Nieminen, Feb 17, 2012
    #15
  16. 在 2012å¹´2月17日星期五UTC+8下åˆ8æ—¶19分34秒,Juha Nieminen写é“:
    > Nick Keighley <> wrote:
    > > I may be missing something obvious, but aren't containers of pointers
    > > useful for polymorphic dispatch?

    >
    > They are, *if* you need polymorphic dispatch. As said, in practice
    > I have needed this very rarely. In the vast majority of cases handling
    > objects by value has been enough.
    >
    > >>   Perhaps GUI programming is something where allocating individual,
    > >> polymorphic objects is needed.

    > >
    > > don't lots of other sorts of programming use lots of polymorphic
    > > objects?

    >
    > Like what, for example?
    >
    > GUI programming is the only type of *practical* situation where
    > polymorphic objects are the best and most natural solution, at least
    > in my own line of work. (It might be different for other types of
    > programming tasks.)


    Don't expect average compuster users to supply
    some customized method to a package to solve a problem.

    The programming literacy rate is still very low now.
    88888 Dihedral, Feb 17, 2012
    #16
  17. On Feb 17, 12:19 pm, Juha Nieminen <> wrote:
    > Nick Keighley <> wrote:
    > > I may be missing something obvious, but aren't containers of pointers
    > > useful for polymorphic dispatch?

    >
    >   They are, *if* you need polymorphic dispatch. As said, in practice
    > I have needed this very rarely. In the vast majority of cases handling
    > objects by value has been enough.
    >
    > >>   Perhaps GUI programming is something where allocating individual,
    > >> polymorphic objects is needed.

    >
    > > don't lots of other sorts of programming use lots of polymorphic
    > > objects?

    >
    >   Like what, for example?
    >
    >   GUI programming is the only type of *practical* situation where
    > polymorphic objects are the best and most natural solution, at least
    > in my own line of work. (It might be different for other types of
    > programming tasks.)


    telecommunications- end user type, simple parsers, call types

    drawing maps- yes that's graphics (so sort of gui) but the graphics
    package i use doesn't provide much support for custom types. It just
    draws things.

    don't a good chunk of the patterns in GoF use inheritance? Though
    perhaps not collections of them. - ah! using a stack of Commands to
    undo
    Nick Keighley, Feb 17, 2012
    #17
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. broli
    Replies:
    3
    Views:
    430
    Kenny McCormack
    Apr 3, 2008
  2. MikeP
    Replies:
    40
    Views:
    1,682
    BartC
    Apr 7, 2011
  3. bert
    Replies:
    1
    Views:
    689
    Nick Keighley
    Apr 6, 2011
  4. rusi
    Replies:
    0
    Views:
    419
  5. Stephan Vladimir Bugaj
    Replies:
    0
    Views:
    131
    Stephan Vladimir Bugaj
    May 5, 2013
Loading...

Share This Page