C++ and Object-Oriented Programming

History & Classification of Languages; Difference between C and C++

C-CAT

History & Classification of Languages

Evolution of Programming Languages

Classification of Programming Languages:

1.1 Procedure Oriented Programming (POP)

  • FORTRAN is the 1st POP Language
  • Examples: C, FORTRAN, PASCAL
  • Focus is on procedures/functions (what to do)
  • Global data shared between functions → security risk
  • Programs structured as a series of function calls

Problems with POP:

  • Global data is accessible to all functions — no data security
  • Not suitable for large, complex programs
  • Difficult to model real-world entities

1.2 Object Oriented Programming (OOP)

  • Simula is the 1st OOP Language (1960)
  • Smalltalk is the only PURELY OOP Language
  • C++ is a partial OOP language (also procedural)
  • Examples: C++, Smalltalk, Java, C#
  • Focus is on objects — data + behavior together

1.3 Object Based Programming

  • Ada is the 1st Object Based Language
  • Examples: Visual Basic, Ada, Modula-2

Has objects but lacks inheritance and polymorphism

1.4 Rule Based Programming

  • Examples: PROLOG, LISP
  • Used in AI, logic programming

C++ History

YearEvent
1979Bjarne Stroustrup begins work on "C with Classes" at Bell Labs
1983Renamed "C++" (++ = increment, as extension of C)
1985First C++ compiler released (CFront)
1998C++98 — first ISO standard
2003C++03 — minor revision
2011C++11 — major update (auto, lambda, smart pointers, range-based for)
2014C++14 — minor additions
2017C++17 — structured bindings, if constexpr, std::optional
2020C++20 — concepts, ranges, coroutines, modules
2023C++23 — further additions

Difference between C and C++

C++ Enhancements over C

FeatureCC++
ParadigmProcedural onlyProcedural + OOP
Classesstruct (no methods)class (data + methods)
EncapsulationNoneYes (public/private/protected)
InheritanceNot supportedSupported
PolymorphismManual (function pointers)Virtual functions
New data typesNo bool typebool, reference type
Function overloadingNot supportedSupported
Operator overloadingNot supportedMost operators overloadable
Default argumentsNot supportedSupported
Inline functionsMacros onlyinline keyword
ReferencesNot supportedSupported
TemplatesMacros onlyFull templates (generics)
Exception handlingerrno, setjmptry-catch-throw
NamespacesNot supportedSupported
Input/Outputscanf/printfcin/cout (streams)
Memory managementmalloc/freenew/delete (with constructors)
STLNoYes (vector, map, string, etc.)
File extension.c.cpp

C++ Input/Output

#include <iostream>
using namespace std;

int main() {
    int x;

    // cin with extraction operator >>
    cout << "Enter a number: ";  // cout = console output; << = insertion operator
    cin >> x;                    // cin = console input; >> = extraction operator

    cout << "You entered: " << x << endl;

    // Multiple inputs
    int a, b;
    cin >> a >> b;
    cout << "Sum: " << a + b << endl;

    // String input
    string name;
    cout << "Enter name: ";
    cin >> name;       // stops at whitespace

    // String with spaces
    string fullname;
    cout << "Enter full name: ";
    getline(cin, fullname);    // reads entire line

    return 0;
}

Continue learning

Related notes

Put this topic into timed practice

Open mock tests when you want full-exam pacing, or keep drilling in practice mode.