From Java to C++

Here at UWB, on the Seattle campus, and at several community colleges, the beginning programming classes (often numbered 142/143 elsewhere) are now being taught exclusively in Java. Our CSS 342/343 are taught in C++. These notes are meant to help you make the transition from Java to C++. The material covered here used to be taught in the CSS 332 course.

It is assumed you understand the basics of object-oriented programming, typically Java. Concepts in Java and C++ are similar, yet C++ has many messier language details. These notes cover these language details. This material is meant to be used for CSS 342, and is presented in a useful order for those courses. Also, the material is example-based, meaning that it is taught through the use of example programs.

It is not thorough in that some language details will not be covered here. These can be found in a C++ language book. These notes cover material on a need-to-know basis. The intention is that they will be as concise as possible but still get the job done. Important language information associated with inheritance and polymorphism is not covered here as it is taught in CSS 343. If you find any errors, serious omissions, or anything isn't "crystal" clear, please email Carol Zander -- zander at u dot washington dot edu

To look up something specific, try Frequently Asked Questions (FAQ)
For many sample programs used in some 342 sections, see Example programs
For some sample inheritance programs used in some 343 sections, see Example programs
If you need more than these notes, besides any decent C++ book, some texts to aid transitioning you from Java to C++ include
  • C++ for Java Programmers, Mark Allen Weiss, Pearson/Prentice Hall
  • C++ for Java Programmers, Timothy Budd, Addison-Wesley
  • C++: Memory first, Adair Dingle & Tom Hildebrandt, Beedle & Associates Inc.

        Language paradigms
        C++ Development/execution environments
        Java vs. C++ architecture, and C++ memory model
        Miscellaneous things about C++
        C/C++ data types, basic operators, and control structures
        Defining consts
        C++ I/O
        Explaining end-of-file I/O
        Static memory allocation and C/C++ arrays
        C++ functions and pass by value vs. pass by reference
        Arrays as parameters to functions
        Template introduction
        Enumerated types

    Object-oriented Programming
        Structured and object-oriented programming in C++
        C++ classes and structs

    Sample C++ class
        The Rational class header file
        The Rational class .cpp
        Using Rational objects, sample driver

        The Rational class -- a better version -- header file
        The Rational class -- a better version -- .cpp
        Using Rational objects -- better version -- sample driver

        Member vs. nonmember operator overloading
        Const data member

    Addressing and memory management in a class
        Memory allocation and deallocation (in relation to OOP in C++)
        The Array class -- header file
        The Array class -- .cpp
        Using Array objects -- sample driver
        Using Array objects -- What happens if you don't write a copy constructor?
        Why not just call the assignment operator from copy constructor?

    More pointers and references
        Revisit parameter passing (C way and passing pointers by reference)
        Pointers and const: What's the const?
        Pointers to functions
        Pointer arithmetic

    Miscellaneous topics
        Information on using MS .net
        Basic Unix commands