←Back to Subject
Notes
Notes
Study material and explanations
Diagrams
Diagrams
Visualize concepts easily
Mnemonics
Mnemonics
Tricks to remember faster
One Night Prep
One Night Prep
Short and focused revision
Revision
Revision
Quick summary and key points
Important Questions
Important Questions
Practice most relevant questions
Notes

C++ History, Applications, Compiling & Linking Process

Study material and explanations for Unit 1

C++ History, Applications, Compiling & Linking Process

1. A Brief History of C++ (In Simple Words)

In 1979, a Danish computer scientist named Bjarne Stroustrup was working at AT&T Bell Laboratories in the USA.

While working on his research project, he ran into a common problem:

  • Simula 67: Had wonderful concepts like classes, objects, and inheritance, but was too slow to run real system tasks.
  • C Language: Was super fast and close to hardware, but lacked modern tools (like classes) to manage large software projects easily.

So, Bjarne decided to combine the best of both worlds:

Speed of C + Object-Oriented Features of Simula = C++!

Milestones in the Evolution of C++
1979: 'C with Classes'
The first version was created by adding classes and basic inheritance to the standard C language.
1983: Renamed to C++
Rick Mascitti suggested the name C++. In C, ++ is the increment operator, meaning "C is upgraded to its next level!"
1985: First Release
First public version released along with Bjarne's famous textbook: 'The C++ Programming Language'.
1998 to Present
Standardized by ISO (C++98), followed by modern versions like C++11, C++14, C++17, and C++20.

2. Where is C++ Used in Real Life? (Applications)

Why do we still study C++ today? Because when a program needs to be lightning fast, companies choose C++:

  1. Operating Systems: Major parts of Windows, macOS, and Linux are written in C and C++.
  2. Video Games & Game Engines: Popular 3D games (like GTA, PUBG) and game engines like Unreal Engine use C++ to achieve 60 to 120+ frames per second without lagging.
  3. Web Browsers: Google Chrome (V8 JavaScript engine) and Mozilla Firefox use C++ to render web pages instantly.
  4. Databases: Fast databases like MySQL and MongoDB run their core engines in C++.
  5. Stock Markets & Banking: High-Frequency Trading systems on Wall Street and Mumbai Stock Exchange process millions of transactions per second using C++.

3. Your First C++ Program Explained Line-by-Line

// First C++ Program: Hello World
#include <iostream>     // Step 1: Include input/output library

using namespace std;    // Step 2: Use standard C++ namespace

int main() {            // Step 3: Main function - entry point of every C++ program
    cout << "Welcome to CampusNotes C++ Programming!" << endl; // Step 4: Print text
    return 0;           // Step 5: Tell the OS that program finished successfully
}

Line-by-Line Breakdown:

  • #include <iostream>: The # symbol is a preprocessor directive. It tells the compiler to attach the input-output stream library before compiling. Without this, cout and cin will not work.
  • using namespace std;: cout and cin live inside a namespace called std. This line saves us from typing std::cout and std::endl on every single line.
  • int main(): Every C++ program must have a main() function. This is where program execution always begins. The int means it returns an integer number to the operating system.
  • cout <<: Pronounced as “see-out”. It is the standard output stream used to print text on the screen. The << operator is called the Insertion Operator (or Put-To operator).
  • cin >>: Pronounced as “see-in”. It is used to take input from the keyboard. The >> operator is called the Extraction Operator (or Get-From operator).
  • endl: Means “end line”. It moves the cursor to the next line (just like \n) and clears the display buffer.
  • return 0;: Returning 0 tells your operating system: “Program executed successfully without any errors!”

4. The 4-Stage Compiling & Linking Process

When you click “Run” in your compiler (like Dev-C++, Code::Blocks, or VS Code), your code passes through 4 automatic stages to become a runnable .exe file:

C++ Build Pipeline
Source Code (.cpp)
Your original code
── Preprocessor ──▶
Expanded Code (.i)
Headers added, comments removed
── Compiler ──▶
Object Code (.obj / .o)
Machine code in binary
── Linker ──▶
Executable (.exe)
Ready to run program

What Happens in Each Stage:

  1. Preprocessing (Preprocessor):
    • Removes all comments (// and /* ... */).
    • Replaces macros (like #define MAX 100).
    • Copies the contents of header files (like <iostream>) directly into the file.
    • Result: A pure, expanded source file (.i).
  2. Compilation (Compiler):
    • Checks your code for grammar and syntax rules (missing semicolons, spelling mistakes, type errors).
    • If everything is correct, converts the C++ code into machine assembly code.
  3. Assembly (Assembler):
    • Converts the assembly instructions into raw binary machine code (0s and 1s).
    • Generates an Object File (.obj on Windows, .o on Linux).
  4. Linking (Linker):
    • Your code called cout, but the actual code that knows how to print pixels to the screen lives inside the C++ standard library.
    • The Linker joins your object file with standard library files and creates the final, standalone Executable File (.exe).

DAVV Exam Preparation Tips

Frequently Asked 5-Mark Questions:

  1. Explain the role of preprocessor directives and header files in C++.
    Model Answer:
    • Preprocessor directives start with # (like #include and #define).
    • They run before the actual compiler starts.
    • #include <iostream> copies the declarations for cin and cout into your program so you can take inputs and print outputs easily.
  2. Why is C++ called an incremental enhancement of C? Who developed it?
    Model Answer:
    • Developed by Bjarne Stroustrup at AT&T Bell Labs in 1979.
    • In C language, the ++ operator means “increment by 1”.
    • The name signifies that C++ contains everything C has, plus powerful Object-Oriented features (Classes, Inheritance, Polymorphism).

Frequently Asked 10-Mark Questions:

  1. Explain the complete compiling and linking process of a C++ program with a neat block diagram. Differentiate between compiler and linker errors.
    Model Answer:
    • Draw the 4-box diagram: Source Code (.cpp) → Preprocessor (.i) → Compiler (.obj) → Linker (.exe).
    • Explain what each step does in simple bullet points.
    • Contrast the two error types:
      • Compiler Error: Happens when you break C++ syntax rules (e.g., missing semicolon ; or using an undeclared variable).
      • Linker Error: Happens after compilation succeeds, but the linker cannot find a function definition (e.g., misspelling main as mian, or missing a library file).