A very brief introduction to C++ in preparation to creative coding using openFrameworks
The purpose of this project is to provide a very brief introduction to the C++ programming language. Through a series of stages, fundamental concepts of C++ are illustrated and described.
The project was created as part of an overall introduction to creative coding using openFrameworks, which is based on C++.
Following a summarized project walkthrough is given, illustrating the single stages of this introduction to C++. Each step of the walkthrough describes the content of the corresponding project folder.
01 - C++ base frame
Illustrating the base frame of every C++ program, concretely the main() function. The function features a simple print out of some text to the standard output stream. Furthermore the syntax of a function in C++ is described.
02 - Statements
Describing different statements in C++, such as declaration statement, assignment statement, output statement and return statement. Furthermore the terminology of initialization and left-hand side (LHS) as well as right-hand side (RHS) are introduced.
03 - Arithmetic operators, void methods and string object
Five different arithmetic operators, concretely +, -, * , / and % (modulo) are introduced. Furthermore, a completely new function of type void, requiring no return statement, is created and called from within the main function. The new function is called printTextAndInt and holds two parameters: A std::string object and an int variable.
04 - More functions and local vs global variables/scope
Functions to add and multiply two variables of type int are created and called from within the main() function. Furthermore, the difference between local and global variables and their accessibility is illustrated.
05 - Namespaces and forward declaration
During this step, the concepts of namespaces and forward declaration within C++ are explained.
06 - Header vs implementation file
Within this step, a header (.h) file is created in order to complement the single implementation (.cpp) file. The difference between function declaration and function definition is emphasized.
07 - More primitive data types, the string object refreshed and the Array collection
Basic primitive (built-in) data types are summarized, concretely int, char, float and bool. Furthermore, a brief introduction to type conversion (type cast) is provided. The array collection and its handling is introduced. Finally, some additional information about the string object are given.
08 - For-loop, while-loop and array iteration
Functionalities in order to iterate and thus execute source code over and over again are illustrated in form of the for-loop and the while-loop. Additionally, an example for the iteration over an array collection is demonstrated.
09 - Branching source code using conditional statements
Using the if-else statement, the switch-statement as well as the conditional operator, different possibilities to branch source code are illustrated, helping the user to react on dynamic conditions directly.
10 - Relational and logical operators
During this step, common relational (==, !=, >, <, >=, <=) and logical (&&, ||, !) operators in C++ are introduced in order to use the full potential of the prior described approaches to create branches in the source code.
MIT License, see LICENSE.md