From C to C++
What C++ adds to C for everyday code: streams for input and output, the string class, references, overloaded functions and default arguments.
About 5 hours of study
Learning objectives
- Read and print with cin and cout
- Use the string class
- Pass arguments by reference and by const reference
- Overload functions and use default arguments
Lessons
- 1
From C to C++
cout and cin, using namespace std, bool and the string class: what C++ adds on top of the C you know.
- 2
References, overloading and default arguments
A reference is another name for a variable; one function name can have several versions; parameters can have default values.
Module practice
- C++: Greeting with cin and coutEasy
- C++: Joining stringsEasy
- C++: Initials from a full nameMedium
- C++: Reverse the words of every lineHard
- C++: Swap with referencesEasy
- C++: Overloaded area()Medium
- C++: Three results through referencesHard