C+= Flashcards
What does a C++ compiler do?
It sequentially goes through each source code (.cpp) file and does 1. check if code follows rules of C++ and 2. translates C++ source code into a machine language file called an object file (.o / .obj)
What does the linker do?
- Takes all object files generated by compiler and combine them into a single executable program (.exe)
- Capable of linking library files
- All cross-file dependencies are resolved properly
What is a statement? Why are they the most common type of instruction?
A statement is a type of instruction that causes the program to perform some action.
They are the smallest independent unit of computation in the c++ lang.
What are Functions? What function must every program have?
Is a reusable sequence of statements designed to do a particular job.
The main function.
What is syntax error?
Is a compiler error that occurs at compile-time when your program violates grammar rules
What is the C++ Standard library?
A library file is collection of precompiled code that has been packaged up for reuse in other programs
What are programs?
Collections of instructions that manipulate data to produce a desired result
What is data and value
Data is any information that can be moved, processed, or stored by a computer. Value is a single piece of data stored in memeory.
What is a variable and identifier?
Variables is a named object while identifier is the name of the object.
What is an object?
Region of storage (usually memory) that has a value and other associated properties
How to create a variable
Use a special kind of declaration statement called a definition.
What is the use of RAM (random access memory)?
Its basically like a bunch of mailboxes that can be used to hold pieces of data while program is running
What is a data type? When must the type of a variable be known?
Tells program how to interpret a value in memory or what type of value the variable will store.
Must be known at compile-time
What happens at runtime when program runs?
The variable will be instantiated. Instantiation mean sobject will be created and assigned a memory address.
What is assignment?
Using the = assignment operator to give a variable a value after it has been defined
What is initialization?
When you provide an initial value for a variable at the same time it is defined
What is default initialization?
When no initialization value is provided
What is copy initialization
When value is provided after an equals sign
What is direct initialization
When value provided inside a parenthesis
int width(5);
What is brace initialization
int width {6};
int height = {6};
int depth {};
Why is brace initialization the best practice
Because it has a benefit to dishallowing narrowing conversions, meaning if you try to use brace to initialize a variable with a value it can not safely hold, the compiler will throw a warning or an error while the other init will truncate or round the number
What is value and zero initialization?
When a variable is initialized with empty braces, value init takes place and will init the variable to zero
What is best practice when initializing your variables?
Initialize upon creation
What is the input/output library?
Part of C++ standard library that deals with basic input/output (keyboard and console)