Introduction about c++


  • Introduction:

                     In 1979, Bjarne Stroustrup, a Danish computer scientist, began work on "C with Classes", the predecessor to C++. 
                   The motivation for creating a new language originated from Stroustrup' s experience in programming for his Ph.D. thesis. 
                   In 1983, "C with Classes" was renamed to "C++" ("++" being the increment operator in C), adding new features that included virtual functions, function name and operator overloading, references, constants, type-safe free-store memory allocation (new/delete), improved type checking, and BCPL style single-line comments with two forward slashes (//). 
Bjarne Stroustrup, the creator of C++
1.1 Bjarne Stroustrup, the creator of C++
                Furthermore, it included the development of a standalone compiler for C++, C front.In 1985, the first edition of The C++ Programming Language was released, which became the definitive reference for the language, as there was not yet an official standard. 
               The first commercial implementation of C++ was released in October of the same year.


  • Objects:

                     C++ introduces object-oriented programming (OOP) features to C. It offers classes, which provide the four features commonly present in OOP (and some non-OOP) languages: abstraction, encapsulation, inheritance, and polymorphism. 
                      One distinguishing feature of C++ classes compared to classes in other programming languages is support for deterministic destructors, which in turn provide support for the Resource Acquisition is Initialization (RAII) concept.
Example of objects
1.2 Example of objects

  • Encapsulation:

             Encapsulation is the hiding of information to ensure that data structures and operators are used as intended and to make the usage model more obvious to the developer. 
               C++ provides the ability to define classes and functions as its primary encapsulation mechanisms. Within a class, members can be declared as either public, protected, or private to explicitly enforce encapsulation. 
               A public member of the class is accessible to any function. A private member is accessible only to functions that are members of that class and to functions and classes explicitly granted access permission by the class ("friends"). 
              A protected member is accessible to members of classes that inherit from the class in addition to the class itself and any friends. 

  •  Inheritance:

              Inheritance is the process ,by which class can acquire the properties and methods of another class. The mechanism of deriving a new class from an old class is called inheritance. 
              The new class is called derived class and old class is called base class. The derived class may have all the features of the base class. 
              The derived class may have all the features of the base class and the programmer can add new features to the derived class. 

Inheritance
1.3 Inheritance

  • Polymorphism

            Polymorphism enables one common interface for many implementations, and for objects to act differently under different circumstances. 
             C++ supports several kinds of static (resolved at compile-time) and dynamic (resolved at run-time) polymorphisms, supported by the language features described above. 
             Compile-time polymorphism does not allow for certain run-time decisions, while runtime polymorphism typically incurs a performance penalty.