This program also uses the standard iostream.h header file to get access to the standard input and output streams, cout and cin . When such a variable is declared, an object is constructed and is stored in the variable. If the constructor requires parameters, they are provided as part of the variable declaration. To get behavior more similar to what happens in Java, you have to use pointers to objects. To have real object-oriented programming, of course, you have to have inheritance and polymorphism.
Inheritance is easy.
Just as in Java, you can declare one class to be a subclass of another. This would be equivalent to saying in Java that ComplexCalc extends SimpleCalc . First of all, polymorphism works only with pointer variables and variables of reference type, never with variables that contain actual objects. A pointer variable can point to objects belonging to some specified class or to a subclass of that class. That is, you would expect that the doSomething method that is called will depend on the type of object that ptr is actually pointing to at the time the statement is executed.