Name visibility

Named entities, such as variables, functions, and compound types need to be declared before being used in C++. The point in the program where this declaration happens influences its visibility: An entity declared outside any block has global scope, meaning that its name is valid anywhere in the code. While an entity declared within a … Continue reading Name visibility

Overloads and templates

In C++, two different functions can have the same name if their parameters are different; either because they have a different number of parameters, or because any of their parameters are of a different type. For example: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 … Continue reading Overloads and templates

Functions

Functions allow to structure programs in segments of code to perform individual tasks. In C++, a function is a group of statements that is given a name, and which can be called from some point of the program. The most common syntax to define a function is: type name ( parameter1, parameter2, ...) { statements … Continue reading Functions

Constants

Constants are expressions with a fixed value.  Literals Literals are the most obvious kind of constants. They are used to express particular values within the source code of a program. We have already used some in previous chapters to give specific values to variables or to express messages we wanted our programs to print out, … Continue reading Constants