Introduction to OOP - Modular Programming

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/31

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 10:35 PM on 5/17/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

32 Terms

1
New cards

What is modular programming

breaking our program into seperate files and functions, each handling a specific task

2
New cards

What are the 3 main benefits of modular programming

readability, reusability, and maintainability

3
New cards

what is readability?

code is easier to understand

4
New cards

what is reusability?

using the same function in multiple programs

5
New cards

what is maintainability?

fixing bugs in one module without effecting the whole program

6
New cards

What goes in header files (.h) ?

types, functions, classes, constant declarations, macros which can be used in multiple files

7
New cards

What are header guards?

#ifndef FILENAME_H
#define FILENAME_H

#endif

8
New cards

what do header guards do?

prevent the file from being included multiple times in the same program

9
New cards

what is extern

used to declare variables/functions that exist in another file

10
New cards

what goes in implementation files (.cpp)?

function and class definitions

11
New cards

what goes in the main file (main.cpp) ?

main() function

include the header file and call the functions

12
New cards

what are namespaces?

containers for related identifiers (functions, variables, classes) that helps prevent naming conflicts

13
New cards

what is the C++ standard namespace?

standard C++ library is defined inside the namespace std::

std::cout << "Hello";

14
New cards

what is a using directive?

using namespace std;
  • used to bring names from a namespace into the current scope

  • this avoids writing std:: everywhere, but can cause naming conflicts in large programs

15
New cards

how to define namespaces?

namespace english {
   int x = 2;
}
// english is the scope name

you define the namespace with the namespace keyword, then declare your identifiers inside its block

16
New cards

how to access elements

english::x;

outside that block, you refer to them using the scope resolution operator :: e.g. namespace::id

17
New cards

what is the compilation process?

process that turns source code into machine code

creates an executable that can run independently of your compiler/IDE

18
New cards

what is source code?

regular text file or multiple text files

19
New cards

What are the steps of compilation?

preprocessing, compilation, and linkage

20
New cards

what does the preprocessor do?

adds contents from included files according to directives

21
New cards

what does the compiler do?

translates the source into an object file containing machine code

22
New cards

what does the linker do

merges together all object code files into an executable

23
New cards

What are some common syntactic errors?

  • normally results in “wrong results”

  • mixing = and == or & and &&

  • uninitialized variable

  • infinite or off by one iterations

24
New cards

what is =

assignment operator

25
New cards

what is the assignment operator used for?

// used to store/change a value in a variable 
int x = 5; 
// meaning: put/store 5 in x

26
New cards

what is ==

equality comparision operator

27
New cards

what is the equality comparision operator used for?

// used to check if two values are equal 
if (x == 10) 
// meaning: Is x equal to 10? 
// this returns true or false

28
New cards

what is &&

logical AND

29
New cards

what is the logical AND used for?

// used to check if both conditions are true
if (x > 0 && y > 0)
// meaning: x is greater than 0 and y is greater than 0
// both must be true for the whole condition to be true

30
New cards

what is &

address operator

31
New cards

what is the address operator used for?

// 1. & as address-of operator
// gets the memory address of a variable
int x = 5;
std::cout << &x;
// meaning: give me the memory address of x

// 2. & in parameters -> reference
void change (int &num)
// meaning: num is a reference to the original variable
// changes affect the real variable

32
New cards

What are the common execution errors?

  • normally results in “crashes”

  • attempting to access invalid memory

  • division by zero

  • unhandled exceptions