1. Object-Oriented Programming (OOP)
Concept: Think of a capsule containing data (attributes/variables) and methods (functions) that operate on that data. This bundles related things together and protects internal data from accidental modification. Classes: You’ll see class definitions, which are the blueprints for creating objects. Private vs. Public: Members declared as private: are only accessible within the class itself. public: members are accessible from outside the class. This is data hiding. Example: A BankAccount class might have private variables like accountBalance and accountNumber, and public methods like deposit() and withdraw(). Concept: Presenting only the essential information and hiding the complex implementation details. Well-defined interfaces: You’ll see classes with public methods that allow you to interact with them, but the underlying data manipulation is hidden. Example: You use a Car object, you press the accelerate() method. You don’t need to know about the engine’s internal combustion process. Concept: Creating a new class (child/derived) based on an existing class (parent/base), inheriting its properties and behaviors. This promotes code reuse and creates “is-a” relationships. class DerivedClass : public BaseClass: You’ll see syntax like this, signifying DerivedClass inherits from BaseClass. protected members: Allows access for children class. Example: A Dog class might inherit from an Animal class, inheriting attributes like name and methods like eat(). Concept: “Many forms.” The ability for objects to take on multiple forms. Method Overloading (Compile-time): Having multiple methods with the same name but different parameter types within the same class. How it appears in code: You’ll see two methods within a class with the same name but different parameter lists Example: A class might have two add() methods: add(int a, int b) and add(double a, double b). Method Overriding (Runtime): A child class providing its own implementation of a method already defined in the parent class. How it appears in code: You’ll see a method in child class with same name and parameter list as in the parent class, usually with virtual keyword in the base class method and override keyword in the child class. Example: The Animal class might have a makeSound() method. Dog overrides it to “Woof!”, Cat overrides it to “Meow!”. Class and Object Definitions: Concept: How classes are defined (blueprint), objects are created (instances), and resources are managed. class MyClass { ... }: Defining a class. MyClass obj;: Creating an object named obj of type MyClass. Constructors: Special methods that are called when an object is created (used for initialization). Example: MyClass() {} Destructors: Special method that is called when an object is destroyed, usually responsible for releasing dynamically allocated resources. Example: ~MyClass() {} Copy Constructors and Assignment Operators: Concept: How objects are copied and assigned. If your class has dynamically allocated memory, you need custom copy constructors and assignment operators to perform deep copies (making copies of the data) rather than shallow copies (copying pointers). Copy Constructor: MyClass(const MyClass& other) { ... } - Creates a new object as a copy of another object Assignment Operator: MyClass& operator=(const MyClass& other) { ... } - Assigns one existing object to another Deep copy: Creating completely new memory for member variables Shallow copy: Only copying memory addresses. 2. Procedural Programming
Concept: A program is broken down into a series of steps (procedures or functions). You will see a sequence of function calls Main function will usually implement program flow Concept: Breaking down large tasks into smaller, reusable functions. You’ll see multiple functions, each with a specific purpose. Concept: Directing the flow of execution. for and while loops: Repeat blocks of code. if, else if, else: Conditional code execution. switch: Multi-way selection. Global vs. Local Variables: Global: Variables declared outside any function, accessible from anywhere in the program (generally discouraged). Local: Variables declared within a function or block, only accessible there. Global variables are at the beginning of your file, not in any function Local variables declared inside function or other scope 3. Structural Programming
Control Structures: Same as in Procedural Programming (loops, conditionals). Concept: Declaring a function’s name, return type, and parameter types before defining it, usually at the beginning of the file or in the header. int myFunction(int x, double y); - Declaring the function Function declaration at the beginning of the file, and the implementation at the end of the file Concept: Identifying and managing potential problems in the program. Checking for invalid user input before processing it. Using if statements to check for errors. 4. Simulation
Concept: Modeling entities and their interactions using classes. You’ll see classes representing the entities being simulated. Concept: One object (subject) can notify other objects (observers) when its state changes. You will see classes implementing methods for subscribing to the subject and updating the observers Encapsulation and Type Definitions: Concept: Using encapsulation to keep data private within objects. Defining custom types (using typedef or enum) to improve code clarity. You will see a class which encapsulates the data You will see a usage of typedef or enum keywords to create custom data types 5. Stack Data Structure
Concept: A stack follows the LIFO (Last-In, First-Out) principle. push(): Adds an item to the top of the stack. pop(): Removes and returns the item from the top of the stack. peek() or top(): Returns the item at the top without removing it isEmpty(): Returns true if the stack is empty. isFull(): Returns true if the stack is full. Dynamic Memory Management: Concept: Allocating memory during program execution (using new) and deallocating it when it’s no longer needed (using delete or delete[]) to prevent memory leaks. Use of new keyword for allocation Use of delete or delete[] keywords for deallocation Use of destructors to free memory Concept: Creating a class to represent the stack. A Stack class with private data members to hold stack elements Implementation of push(), pop(), etc. using dynamically allocated memory and potentially copy constructors for deep copies. What to Learn
Code Structure: Focus on how the code is organized (classes, functions, blocks). Keywords: Pay attention to C++ keywords like class, public, private, protected, virtual, override, new, delete, typedef, enum, this, const, static. Syntax: Understand the syntax for defining classes, methods, creating objects, writing loops and conditionals. Memory Management: Grasp how dynamic memory works and avoid memory leaks. Design Principles: Understand why the code is written this way (OOP, Modularity, etc.) Practical examples: Make sure you understand the code given by professor. Key Takeaways
OOP Principles are fundamental: Understand encapsulation, abstraction, inheritance, and polymorphism well. They will likely form the core of the exam. Practical Application: Don’t just memorize definitions, understand how these concepts are applied. Memory Management is Critical: Pay special attention to deep copying with dynamic memory allocation and deallocation.