C++ tutorials for C programmers?

A

army1987

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.
 
A

Alf P. Steinbach

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
 
J

Jorgen Grahn

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
 
A

Army1987

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.
 
N

Nick Keighley

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++
 
N

none

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
 
S

Silent Stone

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
 
J

Juha Nieminen

Yannick Tremblay said:
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?
 
E

Ebenezer

  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
 
J

Juha Nieminen

Ebenezer said:
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).
 
N

Nick Keighley

  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?
 
N

none

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
 
N

none

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
 
J

Juha Nieminen

Nick Keighley said:
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.
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.)
 
8

88888 Dihedral

在 2012å¹´2月17日星期五UTC+8下åˆ8æ—¶19分34秒,Juha Nieminen写é“:
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.


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.
 
N

Nick Keighley

  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.



  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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top