Section 1.15 Summary
- Computer science is the study of problem solving.
- Computer science uses abstraction as a tool for representing both processes and data.
- Abstract data types allow programmers to manage the complexity of a problem domain by hiding the details of the data.
- C++ is a powerful object-oriented language.
- All variables must be declared before use in C++.
- C++ has typical built-in numeric types:
int
is for integers andfloat
anddouble
are used for floating point depending on the number of digits desired. - C++ has the Boolean type
bool
that holdstrue
orfalse
. - The character data type
char
holds a single character which is encased in single quotes. - Pointers are a type of variable that stores a memory address. To declare a pointer, an
*
is used before the variable name that is supposed to store the location. - A statically allocated C++ array is an ordered collection of one or more C++ data values of identical type stored in contiguous memory.
- A vector is a dynamically allocated array with many useful methods.
- C++ strings are a sequential collection of zero or more characters.
- A hash table is used to store keys-value pairs. It applies a related hash function to the key in order to compute the location of the associated value. Look-up is typically very fast.
- A set is an unordered collection of unique values.
- Arrays, vectors, and strings are C++ sequential collections.
- Hash tables and sets are nonsequential collections of data.
- In C++, a function definition requires a name, a group of parameters, a return type, and a body.
- Non-fruitful functions in C++ must contain the keyword
void
in its function definition. - You can pass variables by value as well as by reference in C++ functions. Passing by reference utilizes the use of pointers.
- Pass by reference is useful when you require a function to return multiple variables.
- To pass an array to a function you need to use an array parameter. The array parameter is denoted by the array variable name followed by set of square brackets ([ and ]).
- Defining a new meaning for an already existing operator (such as the arithmetic operators plus “+” or times “*”) is called overloading the operator. The operators ::, #, ., and ? are reserved and cannot be overloaded.
- Some operators such as =, [], () and -> can only be overloaded as member functions of a class and not as global functions.
- Classes allow programmers to implement abstract data types.
- Programmers can override standard methods as well as create new methods.
- Classes can be organized into hierarchies.
- A class constructor should always invoke the constructor of its parent before continuing on with its own data and behavior.
You have attempted of activities on this page.