C++ is one of the most widely used object-oriented programming languages for desktop application development, because it offers a good middle ground between performance and programming flexibility. The principles used in C++ translate to all object-oriented languages, such as PHP, Java, Python and Objective C. C++ and Objective C are fairly similar, and in fact, they’re both supersets of the C programming language, which means pure C programs can be compiled by either a C++ or Objective C compiler.
Common Uses of C++
While Objective C is used for Macintosh and iOS programming, putting the focus on object introspection and dynamic data allocation, C++ is used for all types of desktop applications and puts more of a focus on static data checked by the compiler, according to Apple. One of the most common uses for C++ is game development with the OpenGL 3-D library. The code that renders 3-D graphics is executed on the graphics processor, but client-side code is needed to set up the game environment, keep track of game objects and generally control the direction of the game.
Most PC games are written in C++, and most independent programmers working with this language are using it to create games. It’s also used for desktop apps like video converters, media players, image editors and pretty much every other type of program that runs on a PC, but relatively few programmers are employed by software companies that make commercial desktop applications.
The Principles of Object-Oriented Programming
C++ is the first language that many programmers learn, because it’s taught in most first- and second-year computer science programs. Learning this language teaches students the fundamental principles of OOP, which are class definitions, object inheritance and polymorphism. Unlike pure C, which isn’t object-oriented, C++ allows developers to define object classes in header files so that very large programs are relatively easy to understand and design. A class is a collection of private data variables with a public interface for manipulating the data. The use of classes makes software more stable because it prevents unwanted access to the data held in memory by the program.
Class inheritance allows programmers to extend a class definition to include new data and new ways to interact with it. This class hierarchy, along with the property of polymorphism, comes with a performance cost that makes C++ programs run a little more slowly than plain C programs, although C++ is still the fastest OOP language.
Polymorphism is the principle of program objects having multiple identities, and it comes about as the result of class inheritance. When a programmer extends a class, it becomes the child of the first class, and objects created from the child class are members of the parent and the child. An object created from a class derived from the child is a member of all three generations, and so on. Polymorphism allows programmers to store collections of disparate objects in the same data structure, and the property of introspection allows programmers to check the type of a variable at runtime.
Related Resource: Python