#C,C++ Books
25 messages in this thread
I'm looking for a good C or C++ book. I learnt C about 7 years ago but haven't
used it in a few years and so I sort of forgot alot of stuff. I'm not too sure
what C++ is, but I hear it's the same as C with extra commands?
I've heard of two books called C++ Programming by Bjarne Stroustrip (not sure
if I have the name right), and other one called C++ Primer by a Mr. Lippman.
Does anybody know which of these books is the best? Or if there's another book
I should be considering?
I want to stop being a user of other programs that never do exactly what I want
and start writting some of my own 🙂
Thanks for any information you have!
You want Lippman for learning, Stroustroup for reference. Actually, there
might be a better learning book (maybe the Waite groups'), but Lippman is
the one with the popular vote.
— Dale L. Larson, Intangible Assets Manufacturing
— INTERNET:dale@iam.com
Thanks for your reply. I have heard that the Waite group has a book called the
C++ bible and was told to get that one.. but I couldn't find it here. I did
find the other two though.. and so I guess I'll get Lippman.
Since I just have been trying to use SAS 6.50 I can tell you C++ is not C
with more stuff (at least not the way I was thinking of it, I thought I
had a good idea about OOPs (OK, folks, let's not get into that discussion
ie. is C++ OOPs or not)). I've bought a few books and am still looking for
a really good one. Let me know if you find something, K?
Robb
Well, what is the difference between C and C++? I have heard that C++ is object
oriented, but that doesn't mean much to me right now.
You might think of C++ in two parts.
First there are enhancements to the C language. These range all the way from
an easy single-line comment (just start the line with //) to more elegant
input/output [printf() replaced by cout, which in many cases will figure out
what format is wanted for each variable]. In general, these make coding a
little faster, although they don't tend to reduce the size of your final
program. There are LOTS of these enhancement features.
Second, you might say C++ is a "class" act; here's where it gets into object
oriented stuff. If you know how C deals with structures, think along these
lines: first, C++ can make certain parts of the structure "private" so that no
outside code can look at these. Next, the structure can contain, not only
data, but code, to handle parts of itself (especially those private bits). By
the time we do all this, the "structure" may be renamed a "class".
It works out this way: whereas in C, a program makes, loads, and changes a
structure at will, in C++ it doesn't have access. It must make application to
one of the embedded functions (say, "add an item", "find an item", "change an
item", "delete an item") in order to interact with the structure (class) data.
In particular, stuff like the links in a linked list will never be seen by
"outside" code. And the calling program doesn't need to know everything that's
in the data, or how it's organized; it just asks for what it wants.
This type of Object Oriented Programming tends to encapsulate data into a
separate module. Not just the data, of course: code can also be encapsulated
in its own private module; C already does this to some extent with separate
procedures.
Trust this rather shallow outline will give you an idea of where C++ will
take you.
–Jim
Jim,
I have never seen the differences between C and C++ summarised so
explicity and concisely – well done.
Tony.
Driving my deck on AutoPilot
For those kind words, much thanks, Tony. Now if I can stop extemporizing on
the principles and put out some dynamite code that REALLY shows the style of
the language .. I will truly feel like I've got it whipped.
–Jim
Yeah, Jim – when are we going to see some of your cute stuff in our
library here? I'm sure you have some tucked away somewhere.
—Betty
Thanks for that description on C++. I sort of understand what you are talking
about.. I'll keep the msg around until I start to remember more code and see if
I understand it a little better later on. I'm also a little sick today.. so
maybe my brain is off. 🙂
Patrick,
I couldn't even come close to the response you got from Jim.
Robb
Patrick,
The rest of my message was truncated by the system it seems. Here's the rest…
In this case, SHAPE may have a single method (member function): area(). CIRCLE
and SQUARE would inherit this (and in a real shape class, other data members
and member functions too) and then ADD EXTRA data members and functions. You
could derive a hundred other shape classes from SHAPE and they could all be
compared to one another so long as they implemented an area function.
The ideas of one class inheriting the properties of another and delaying the
decision about which method to employ until run-time are very powerful.
Another powerful feature in C++ is polymorphism which while not strictly OO, is
great when combined with OOP. The example I just gave is a kind of polymorphism
since one function can handle more than one class type implicitly.
Here's a clearer example of polymorphism: suppose you want to add two strings
together. In BASIC, strings are a first-class data type so you can add strings
together easily. The "+" operator is said to be overloaded since you can add
numbers AND strings together, ie. "+" is a polymorphic operator.
In C++ it is possible to create a string class such that EVEN THOUGH STRINGS
ARE NOT A FIRST-CLASS DATA TYPE IN C++, they can become so. You can overload
"+" and "=" so that the following is possible:
stringA = stringB + stringC
You can also overload "*" to multiply matrices, etc.
Jim mentioned the use of cin and cout (iostreams), which is another example of
polymorphism.
There are other features in C++ such as templates which allows you to create a
generic stack class for example. You can later declare a stack of integers,
reals, etc from a SINGLE class template. This is a kind of macro expansion
facility.
If you (or anyone else) would like some C++ code examples for anything
mentioned above (or anything else in C++), please feel free to ask.
Also, I think it's important to mention that unlike C, there is still no
official C++ standard yet. The first ANSI/ISO draft standard is due to be
released for public comment within the next couple of months. However, the
standard C library will be included (with minor mods).
I/O streams is also a part of the standard. There are differences between
compilers at present which the standard will hopefully resolve down the track.
Regards,
David Benn (author of ACE)
Robert,
I don't know if it's any good or not (I've just read the first chapter)
but I picked up "Teach Yourself C++" by Herbert Schildt (Osborne
McGraw-Hill). It is for the C programmer wanting to learn C++ … so all
the basic C stuff (C++ is just an extension to C) is not taught.
-sja
Steve,
OK. I'll head to the bookstore tomorrow (I've printed that out to take
with me), but I'm still not convinced that C++ is really an extension to C
(I know C), C++ is, definitely, a differnet way of looking at things.
Robb
Robert,
C++ is nothing more than an enhanced version of the C language. C++ includes
everything that is part of C and adds support for object oriented programming.
With very few, very minor exceptions, C++ is a superset of C. Everything you
know about C is fully applicable to C++. Understanding C++'s enhanced
features, on the other hand, will require time and effort.
Some people make the point that, if you are getting the most out of C++,
it will be like a completely different langauge because you are doing
everything in different (OO) ways. On the other hand, lots of people use
C++ as a better C (skipping most OO features or using them only
occationally), and that is fine, too.
— Dale L. Larson, Intangible Assets Manufacturing
— INTERNET:dale@iam.com
Dale,
It really doesn't matter too much how you use C++ (except maybe to an
employer). C++ is a superset of C. You could technically call any C program a
C++ program (altho the reverse wouldn't be true).
>You could technically call any C program a C++ program
For any well-written ANSI C program, this is absolutely true.
— Dale L. Larson, Intangible Assets Manufacturing
— INTERNET:dale@iam.com
Steve,
OK. I guess I really meant exactly what you are saying. A well versed C
programmer cannot just walk up to a piece of code that truly used the C++
extensions and figure out what it's doing. It takes consderable effort to
make the jump. I don't know how big that jump is 'cause I've only taken
the first few steps and realize that the alien code I'm presented with
really isn't to difficult, once you see how it works. Pretty basic. But,
the extensions are rather extensive and can use a considerably different
mindset than 'normal' C.
Robb
You might try "Developing C++ Software" 2ed by Russel Winder, published by
Wiley, ISBN 0 471 93610 3. I thought it was quite good.
Steve the G. [BEDFORDSHIRE, UK]
Thanks, I'll try and take a look at that one too.
I don't have either book but both were recomended on another system. If
you can, look them over before you buy.
The first books name was listed over there as "The C++ Programming
Language" by Stroustrup.
//
\X/ Amiga or bust! Gary Bonnstetter, Bonnsoft
Patrick
My favorite right now is a book by Scott(?) Meyer(s). I can't find the
book but the three of us here thought it was the most readable of the
collection we have.
That's Bertrand Meyer. He's the inventor of the Eiffel OO programming language.
The book you're referring to is probably "Object Oriented Software
Construction",
1988, Prentice-Hall.
He may have written another one, more specifically oriented to Eiffel: "The
Eiffel Programming Language" or similar.
Regards,
David Benn
Wrong guy, but I can't dig up the right name or title either.
— Dale L. Larson, Intangible Assets Manufacturing
— INTERNET:dale@iam.com