C++ Programming Exam Notes
Unit I – Input Output & Functions in C++
**Unformatted I/O**: Basic input/output without formatting (e.g., cin, cout).
**Formatted I/O**: Input/output with format control using manipulators (e.g., setw,
setprecision).
**Insertion & Extraction Operators**: Operators << and >> used with cin and cout.
**Function Declaration and Definition**: Declaring the function prototype and writing the
body.
**Return Values**: The output a function provides after execution.
**Arguments**: Inputs passed to a function.
**Call by Value**: Sends a copy of the variable.
**Call by Reference**: Sends the address of the variable.
**Call by Pointer**: Similar to reference, but using pointers.
**Recursion**: A function calling itself.
**Inline Functions**: Functions expanded at compile time to reduce overhead.
**Function Overloading**: Defining multiple functions with the same name but different
parameters.
**Pointers**: Variables storing memory addresses.
**Structures**: User-defined data types for grouping different types.
**Union**: Similar to structures, but shares memory among members.
Unit II – Object-Oriented Features of C++
**Class and Object**: A class is a blueprint; an object is an instance of it.
**Data Hiding**: Restricting access using private/public keywords.
**Encapsulation**: Binding data and methods together.
**Abstraction**: Hiding internal details and showing only functionality.
**Data Members & Member Functions**: Variables and functions inside a class.
**Empty Class**: A class with no data or functions.
**Scope Resolution Operator (::)**: Access global variables or class members.
**Static Data Members**: Shared by all objects of the class.
**Friend Function/Class**: Allows non-members to access private data.
**Constructors**: Special function to initialize objects.
**Types of Constructors**: Default, parameterized, copy constructor.
**Destructors**: Clean-up function when object goes out of scope.
**Dynamic Initialization**: Initializing objects at runtime using constructors.
Unit III – Operator Overloading & Inheritance
**Operator Overloading**: Redefining operators for user-defined types.
**Unary/Binary Operators**: Operate on one/two operands (e.g., -, +).
**Inheritance**: Deriving a class from another.
**Derived Class**: The new class.
**Base Class**: The existing class.
**Types**: Single, multilevel, multiple, hierarchical, hybrid.
**Access Specifiers**: Public, private, protected—control member access.
**Virtual Base Class**: Prevents duplication in multiple inheritance.
**Abstract Class**: A class with at least one pure virtual function.
Unit IV – Virtual Functions, Polymorphism & Exception Handling
**Virtual Function**: Base class function redefined in derived class.
**Pure Virtual Function**: No body in base class; must be overridden.
**Polymorphism**: Same function behaving differently in different contexts.
**Exception Handling**: Managing errors during program execution.
**try/catch/throw**: Blocks used to handle exceptions.
**Catch All**: catch(...) catches any exception.
**Nested try Blocks**: try inside another try.
**Uncaught Exceptions**: Exceptions not handled cause program to crash.
Unit V – Practicum Overview
Write C++ programs to:
- Print messages (e.g., Your intro, Institute intro).
- Swap numbers.
- Use ternary operators to check even/odd and find max.
- Use constructors and destructors.
- Create and use a class with members like Length, Breadth, Height.
- Calculate volume using member functions.
- Overload constructors.
- Demonstrate exception handling.