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
| Year | Event |
|---|---|
| 1979 | Bjarne Stroustrup begins work on "C with Classes" at Bell Labs |
| 1983 | Renamed "C++" (++ = increment, as extension of C) |
| 1985 | First C++ compiler released (CFront) |
| 1998 | C++98 — first ISO standard |
| 2003 | C++03 — minor revision |
| 2011 | C++11 — major update (auto, lambda, smart pointers, range-based for) |
| 2014 | C++14 — minor additions |
| 2017 | C++17 — structured bindings, if constexpr, std::optional |
| 2020 | C++20 — concepts, ranges, coroutines, modules |
| 2023 | C++23 — further additions |
Difference between C and C++
C++ Enhancements over C
| Feature | C | C++ |
|---|---|---|
| Paradigm | Procedural only | Procedural + OOP |
| Classes | struct (no methods) | class (data + methods) |
| Encapsulation | None | Yes (public/private/protected) |
| Inheritance | Not supported | Supported |
| Polymorphism | Manual (function pointers) | Virtual functions |
| New data types | No bool type | bool, reference type |
| Function overloading | Not supported | Supported |
| Operator overloading | Not supported | Most operators overloadable |
| Default arguments | Not supported | Supported |
| Inline functions | Macros only | inline keyword |
| References | Not supported | Supported |
| Templates | Macros only | Full templates (generics) |
| Exception handling | errno, setjmp | try-catch-throw |
| Namespaces | Not supported | Supported |
| Input/Output | scanf/printf | cin/cout (streams) |
| Memory management | malloc/free | new/delete (with constructors) |
| STL | No | Yes (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
Definition of AI; Need of AI
Artificial Intelligence
Introduction to Data Engineering; Big Data — The 5 V's; Types of Data
Big Data and Data Engineering
Introduction to C Programming; C Program Structure; Data Types and Variables
C Programming
What Is a Computer?; Machine Cycle: Fetch–Decode–Execute; CPU Organization
Computer Architecture
Put this topic into timed practice
Open mock tests when you want full-exam pacing, or keep drilling in practice mode.