An easy to read book written for someone who has one or more years experience of Java and who wants to learn C++. As the author points out, a book of its size can not be a complete and thorough introduction to C++. The book goes through the differences between the two languages and provides some simple examples, throughout the main text and concludes with four case studies, see chapters 14 to 17. Each chapter ends with a short quiz to test your understanding.
However the code examples are rather bitty
and don't really show the reader how all the concepts in C++ fit together. Also it is not clear if the code examples comprise a working a working program. Another drawback is that the example code is presented within the describing text, and there is no attempt to identify the files the code should be put in. As the author informs in chapter 5, classes are defined in multiple files in C++, a novice Java programmer needs assistance to work out how to organise their class files, and how they should be subsequently linked. This book does not provide this information at all. For the code for case study 3, it is difficult to work out how the GUI should be implemented.
Although chapter 16 uses the Microsoft Foundation Classes (MFC) for the graphical interface, the book does not appear to use any code that is compiler/vendor specific. However I have not used any code in the book, so we can not confirm this.
At the end of the day, you are probably better off buying a book solely on C++ and learning the language from scratch rather than purchasing this book.
4 Sep 2001
Discusses the fundamental data types, including;
main
, alternative main
entry points)While pointers are hidden to the Java programmer, the use of pointers in C++ is explicit and direct and the language provides a variety of different mechanisms for manipulating pointer values. The chapter covers;
const
, void *
pointers, to functions)In Java the task of memory management is conducted pretty much in the background. However in C++ the programmer is responsible for memory management, which leads to a variety of errors that the Java programmer may not be aware of. The chapter covers;
Although both Java and C++ both use classes, this chapter introduces the many differences in the way that classes are implemented in the two languages.
Covers the differences between polymorphism in Java and C++.
Object
Something new to the Java programmer, C++ provides the ability to overload operators. The chapter describes the benefits and dangers of doing this.
cctype
library and cstring
)The template mechanism in C++ is one of the more complex features in the language that has no correspondence in Java. A template allows a class or function to be parameterised by values or types. With the mechanism being performed statically at compile time this permits a great deal of type checking to be performed then rather than at run-time. This eliminates many of the performance reducing run-time casts typically required in Java programs.
A major use of templates has been as a tool to develop a rich set of data structures, containers and abstractions, part of which have become the Standard Template Library (STL), which is the primary data structure library used in C++ programs.
The techniques used for I/O in Java are based on those developed in C++. The chapter covers the differences between the two languages, as well as the complications due to the two competing I/O systems in C++, the stdio
inherited from C, and the newer C++ specific library called the Stream I/O Library.
stdio
Library, (formatted output)Unlike Java, exception handling is a relatively new addition to C++. Before its introduction C++ programmers used a variety of ways to handling abnormal situations. So in addition to knowing the C++ exception handling mechanism, the Java programmer must know the alternatives available.
setjmp
and longjmp
facilityfinally
clause, references as exceptions, exception class clonability, no need to document exceptions, standard exceptions)This section summarises the features introduced in earlier chapters that have no equivalent in Java, as well as describing some of the remaining features that are only found in C++ that have not been discussed.
typedef
statementconst
keywordgoto
statementHowever, the number of features in Java that have no C++ equivalent are relatively small. Most have been highlighted in the book's earlier chapters and the most notable remaining ones are listed in this chapter.
A case study to illustrate the use of constructors, overloaded operators, conversion operators, assignment and the stream style of input and output, through the creation of a data abstraction of an integer fraction, or rational number. The aim is to create a data abstraction that operates as much as possible like the primitive arithmetic types such as float or integer.
Illustrates the use of several of the container classes provides as part of the STL using two examples. The first is an algorithm for computing the shortest path between pairs of points. The second involves scanning a text document and developing a concordance.
This case study examines a simple version of the card game solitaire. Covered at the creation of a general purpose, reusable containers, the implementation of the game and an introduction to the Microsoft Foundation Classes (MFC) for the graphical interface.
Note,
The application presented uses the merest fraction of the functionality provided by the MFC. The author recommends MFC Programming from the Ground Up, Herbert Schidt, McGraw-Hill, New York, 1996 as a good introduction.
A common problem encountered by programmers is how to combine elements from two or more classes when they are not permitted to make changes to the original classes, for example, the original classes might be distributed in binary form from separate vendors. However the programmer wishes to maintain these classes in a common representation and perform common tasks on them.
Because the classes are distributed in binary form it is not possible to a new member function, but this chapter describes how to write new ordinary functions that take their respective types as arguments.