Learning C++

D

davineastley

Hello,

My name is Davin Eastley and I'm 13 years old. I live in Tasmania,
Australia and am training for MCAD Certification in C#. I was
interested to know what the best resources for learning C++ is as I am
a beginner. I later want to learn Java as well.
Feel free to e-mail me at (e-mail address removed).

Regards,
Davin Eastley
 
A

Alf P. Steinbach

* (e-mail address removed):
My name is Davin Eastley and I'm 13 years old. I live in Tasmania,
Australia and am training for MCAD Certification in C#. I was
interested to know what the best resources for learning C++ is as I am
a beginner. I later want to learn Java as well.

Generally agreed on to be good introductory books:

Francis Glassborow "You can do it!"
Andrew Koenig and Barabara Moo "Accelerated C++"

Do avoid books that are full of errors, such as "in 24 hours".

The one and only nearly correct free C++ tutorial, under development,
which is my own:

<url: http://www.parashift.com/c++-faq-lite/newbie.html#faq-29.20>

OK, that link is to the FAQ: you'll need to study FAQ, and that's
where you'll find answers to common questions.

One of the few full, free C++ textbooks:

Bruce Eckel "Thinking in C++"

However, that book is old and not quite correct in all details,
but almost all who have used it report it's great to learn from.

Feel free to e-mail me at (e-mail address removed).

Ask here, get answers here: it's about thinking about others.
 
D

davineastley

Thank you for your speedy reply, Alf. I have heard some good things
about Accelerated C++ before. I think I might go and pick up a copy for
myself. Thank you for the link to your C++ tutorial. I will also take a
look at Thinking in C++. I noticed that the cplusplus.com website has a
tutorial. In your opinion, is this any good? I thank you again.

Regards,
Davin Eastley
 
A

Alf P. Steinbach

* (e-mail address removed):
Thank you for your speedy reply, Alf. I have heard some good things
about Accelerated C++ before. I think I might go and pick up a copy for
I will also take a
look at Thinking in C++. I noticed that the cplusplus.com website has a
tutorial. In your opinion, is this any good?

Not in my opinion, but simple fact: the very first example in that
tutorial is

#include <iostream.h>

int main ()
{
cout << "Hello World!";
return 0;
}

which is incorrect in several respects and won't compile with a modern
compiler such as Visual C++ 7.x.

From the [alt.comp.lang.learn.c-c++] FAQ, at

<url: http://ma.rtij.nl/acllc-c++.FAQ.html#q7.1>

"There are few, if any, credible tutorials for standard C++ online. Your
best bet is a reliable textbook"

That was the main reason I started on one (the above quoted advice was
written before that, the newbie FAQ item in the C++ FAQ, after).
 
D

davineastley

Thanks for that information, Alf. I thank you for that.Thanks again. I
will take a look at that link shortly.

Regards,
Davin Eastley
 
V

velthuijsen

My name is Davin Eastley and I'm 13 years old. I live in Tasmania,
Thank you for your speedy reply, Alf. I have heard some good things
about Accelerated C++ before. I think I might go and pick up a copy for
myself. Thank you for the link to your C++ tutorial. I will also take a
look at Thinking in C++. I noticed that the cplusplus.com website has a
tutorial. In your opinion, is this any good? I thank you again.

You can download the "thinking in C++" books from
http://www.mindview.net/ (books section).
Once you get through either (or all) of the suggestions of Steingbach
you might want to take a peek at www.accu.org and start looking through
the book review section (also has reviews of books for C# and Java
since that is what you are also looking for).
 
A

Alf P. Steinbach

* John Carson:
Old?

"Volume 1 Completed: January 13, 2000

"July 9, 1998: Changed all fonts to Times and Courier (which are universal);
changed distribution format to RTF."

Btw., my copy has some corrections dated January 31 2000, which seems to
be _after_ the completion date of your copy... ;-)

One example of what I mean by "old" is the section "Standard include
format" in chapter 1, which includes incorrect information that at
the time of writing could be _in-practice_ correct, but not as of 2005:

<quote>
instead of the old style of including iostream.h, which looks like this:
#include <iostream.h>
you can now write:
#include <iostream>
</quote>

The two statements do not have the same effect, as Bruce implies here (and
which they had with some compilers at the time), and as of 2005 <iostream.h>
doesn't exist with some compilers, and it's never been part of standard C++
anyway -- it's not _can_, or even "in practice you can", now it's _must_.

Cheers,

- Alf
 
D

davineastley

Thanks for your replies everybody. I appreciate it. I had searched for
the books in Google and I have downloaded the second edition of
Thinking in C++. I haven't read any yet. I have previously heard of
accu.org for C/C++ programmers. In my case, I'm starting to learn C++.
Thank you for the posts, again.

Regards,
Davin Eastley
 
J

John Carson

Alf P. Steinbach said:
* John Carson:

"July 9, 1998: Changed all fonts to Times and Courier (which are
universal); changed distribution format to RTF."

And there are about 30 entries after that, e.g.,

"TIC2VoneR6: November 29, 1999. Rewrote Chapter 12 & added exercises.
Rewrote Chapter 13 & added exercises. Rewrote Chapter 14 & added exercises.
Chapter 4, 5, 6, 7, 8, 9 & 10 have been copy-edited. Fixed a bug in all the
"stash" examples. Made the constructor calls more consistent throughout.
Corrected files so that "make test" generally works (although VC++ doesn't
handle the int main( ) return type as per the Standard, so it doesn't work
for that). Changed all the examples from the const chapter on so that they
have const member functions and take const& arguments where possible (that
is, implemented const correctness)."
One example of what I mean by "old" is the section "Standard include
format" in chapter 1, which includes incorrect information that at
the time of writing could be _in-practice_ correct, but not as of
2005:

<quote>
instead of the old style of including iostream.h, which looks like
this: #include <iostream.h>
you can now write:
#include <iostream>
</quote>

The two statements do not have the same effect, as Bruce implies here
(and which they had with some compilers at the time), and as of 2005
<iostream.h> doesn't exist with some compilers, and it's never been
part of standard C++ anyway -- it's not _can_, or even "in practice
you can", now it's _must_.

I don't think there is any justification for calling the book old, even if
it does show an occasional sign that it was not published in 2005. As for
your quoted passage, I would agree that the use of the word "can" is
unfortunate, but it is worth noting that, immediately prior to the passage
you quote (which, curiously enough, occurs in Chapter 2 of my copy), we
read:

"To smooth over these rough edges, the standard uses a format that allows
file names longer than the notorious eight characters and eliminates the
extension."

There is no suggestion that it is optional in this sentence. I also point
out that he uses the extension-free form throughout the book.
 
A

Alf P. Steinbach

* John Carson:
* Alf P. Steinbach:

I don't think there is any justification for calling the book old, even if
it does show an occasional sign that it was not published in 2005. As for
your quoted passage, I would agree that the use of the word "can" is
unfortunate, but it is worth noting that, immediately prior to the passage
you quote (which, curiously enough, occurs in Chapter 2 of my copy), we
read:

"To smooth over these rough edges, the standard uses a format that allows
file names longer than the notorious eight characters and eliminates the
extension."

There is no suggestion that it is optional in this sentence.

There is such suggestion around that place in the text.

And it becomes worse later on, same chapter:

<quote>
if you say
#include <iostream.h>
it means
#include <iostream>
using namespace std;
</quote>

But as I wrote to the OP, most people who have used the book report
that it's great to learn from.

Although there are many more goofs similar to those above, that is,
both formally and practically incorrect, they don't matter much as
long as the student refrains from applying the information.

The big problem is, however, that many folks then go around with
incorrect "explanations", and pass those misconceptions on to others,
so that we have to straighten them out when they finally _ask_.

I also point out that he uses the extension-free form throughout
the book.

Ah, it's difficult to respond to that without it seeming like I'm
bashing the book.

I'm not.

With that in mind (I'm not out to bash the book, just countering your
implied argument that it _teaches_ standard C++), after skimming along
for the first obvious fundamentally incorrect information, I found in
chapter 5 a section named "Nested friends" where Bruce writes

<quote>
Making a structure nested doesn’t automatically give it access to
private members. To accomplish this, you must follow a particular
form: first, declare (without defining) the nested structure, then
declare it as a friend, and finally define the structure.
</quote>

where he then goes on to _exemplify_ that incorrect statement by
the incorrect code

struct Holder {
private:
int a[sz];
public:
void initialize();
struct Pointer;
friend Pointer;
struct Pointer {
// ...
};
};

Says Comeau online:

"ComeauTest.c", line 14: error: omission of "struct" is nonstandard
friend Pointer;
^
1 error detected in the compilation of "ComeauTest.c".

Removing that silly

struct Pointer;
friend Pointer;

makes the code correct (and then it also compiles... ;-)).
 
C

Chris Theis

Alf P. Steinbach said:
* (e-mail address removed):

Not in my opinion, but simple fact: the very first example in that
tutorial is

#include <iostream.h>

int main ()
{
cout << "Hello World!";
return 0;
}

which is incorrect in several respects and won't compile with a modern
compiler such as Visual C++ 7.x.

This glitch was actually corrected in the 2nd edition (2000) and I
hope/guess some others too. Although TIC++ is (IMHO) not bad, the language
has evolved in the last 5 years. One just has to consider that the last
standard dates to 2003. Therefore, I would also recommend Alf's tutorial as
a starting point.

Cheers
Chris
 
A

Andrew Koenig

Generally agreed on to be good introductory books:
Francis Glassborow "You can do it!"
Andrew Koenig and Barabara Moo "Accelerated C++"

I'd like to add one to this list:

Lippman, Lajoie, and Moo: "C++ Primer, 4th Edition"

If you look around at online reviews, please be aware that most of them (in
particular, any dated before about mid-February 2005) refer to the third
edition, and the 4th edition is completely rewritten and reorganized.

Whether you prefer "C++ Primer" or "Accelerated C++" depends on your
learning style--that's part of the reason that both books exist instead of
only one of them.
 
J

John Carson

Alf P. Steinbach said:
And it becomes worse later on, same chapter:

<quote>
if you say
#include <iostream.h>
it means
#include <iostream>
using namespace std;
</quote>

His comments reflect an intermediate state of compilers in regard to this
issue. However, once again, the surrounding text indicates what the standard
actually says:

"Before the modern header file inclusion was standardised (without the
trailing '.h', as in <iostream>), the typical way to include a header file
was with the '.h', such as <iostream.h>... So to provide backward
compatibility with existing code
[your quote follows]
However in this book the standard include format will be used (without the
'.h') and the using directive must be explicit."

Again, he should have made it clearer that he was talking about a compiler's
implementation of backward compatibility, rather than the standard's, but
readers should come away with the correct practice.
With that in mind (I'm not out to bash the book, just countering your
implied argument that it _teaches_ standard C++), after skimming along
for the first obvious fundamentally incorrect information, I found in
chapter 5 a section named "Nested friends" where Bruce writes

<quote>
Making a structure nested doesn’t automatically give it access to
private members. To accomplish this, you must follow a particular
form: first, declare (without defining) the nested structure, then
declare it as a friend, and finally define the structure.
</quote>

where he then goes on to _exemplify_ that incorrect statement by
the incorrect code

struct Holder {
private:
int a[sz];
public:
void initialize();
struct Pointer;
friend Pointer;
struct Pointer {
// ...
};
};

Says Comeau online:

"ComeauTest.c", line 14: error: omission of "struct" is nonstandard
friend Pointer;
^
1 error detected in the compilation of "ComeauTest.c".

Removing that silly

struct Pointer;
friend Pointer;

makes the code correct (and then it also compiles... ;-)).

In the source code supplied with the book,

friend Pointer;

is replaced with

friend struct Pointer;

and it does indeed compile on Comeau. You are, however, correct that the two
lines of code are redundant.

You are correct that the book contains occasional errors and does not
reflect the very latest changes to the standard. In an imperfect world, I
consider the book's defects to be minor.
 
D

davineastley

Thanks everyone. That's great! Andrew, I noticed you are a co-author of
Accelerated C++. I am going to pick up a copy but I haven't found it at
any Angus & Robertson store yet... I have heard many good comments
about this book ;-). Good work!!

Regards,
Davin Eastley
 
A

Alf P. Steinbach

* Chris Theis:
* Alf P. Steinbach:
* Davin Eastley:

Not in my opinion, but simple fact: the very first example in that
tutorial is

#include <iostream.h>

int main ()
{
cout << "Hello World!";
return 0;
}

which is incorrect in several respects and won't compile with a modern
compiler such as Visual C++ 7.x.

This glitch was actually corrected in the 2nd edition (2000) and I
hope/guess some others too. Although TIC++ is (IMHO) not bad, [...]

Ahum.

The "glitch" (horrendous pre-standard incorrect code) is from the tutorial
at <url: http://www.cplusplus.com/doc/tutorial/tut1-1.html>.

The purported correction is in the 2nd edition (2000) of Thinking in C++?
 
D

davineastley

Thanks. This material will help me learn. If anyone else knows of some
good material, please post messages here to share with me and other
users.

Regards,
Davin Eastley
 
C

Chris Theis

Alf P. Steinbach said:
* Chris Theis:
* Alf P. Steinbach:
* Davin Eastley:
I noticed that the cplusplus.com website has a
tutorial. In your opinion, is this any good?

Not in my opinion, but simple fact: the very first example in that
tutorial is

#include <iostream.h>

int main ()
{
cout << "Hello World!";
return 0;
}

which is incorrect in several respects and won't compile with a modern
compiler such as Visual C++ 7.x.

This glitch was actually corrected in the 2nd edition (2000) and I
hope/guess some others too. Although TIC++ is (IMHO) not bad, [...]

Ahum.

The "glitch" (horrendous pre-standard incorrect code) is from the tutorial
at <url: http://www.cplusplus.com/doc/tutorial/tut1-1.html>.

The purported correction is in the 2nd edition (2000) of Thinking in C++?

Sorry, my fault. I missed that you're actually refering to the cplusplus.com
tutorial and not TIC++. The example is corret in TIC++ (at least the 2nd
edition as I didn't check the previous one).

Chris
 
D

davineastley

Thanks everybody. I am yet to pick up a copy of Accelerated C++ as I
have heard many good things about this book. Do any companies have
certifications in C++? I would be interested in training for them after
the learning curve stage (however everyone continues to learn and never
stops). If anyone else can recommend some good reference material, that
would be appreciated.

Regards,
Davin Eastley
 

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

No members online now.

Forum statistics

Threads
474,142
Messages
2,570,818
Members
47,362
Latest member
eitamoro

Latest Threads

Top