''Combine old and newer features to get the best out of the language'' ... Containers: list, vector, set, map ⦠â ..
CPP
Modern C++ Object-Oriented Programming ''Combine old and newer features to get the best out of the language'' Margit ANTAL 2017
C++ - Object-Oriented Programming Course content –
Introduction to C++
–
Object-oriented programming
–
Generic programming and the STL
–
Object-oriented design
2
C++ - Object-Oriented Programming References –
Bjarne Stroustrup, Herb Sutter, C++ Core Guidelines, 2017.
–
M. Gregoire, Professional C++, 3rd edition, John Wiley & Sons, 2014.
–
S. Lippman, J. Lajoie, B. E. Moo, C++ Primer, 5th edition, Addison Wesley, , 2013.
–
S. Prata, C++ Primer Plus, 6th edition, Addison Wesley, 2012.
–
N. Josuttis, The C++ standard library. a tutorial and reference. Pearson Education. 2012.
–
A. Williams, C++ Concurrency in Action:Practical Multithreading. Greenwich, CT: Manning. 2012.
3
Module 1 Introduction to C++
4
Why would you learn C++?
5
Introduction to C++ Content –
History and evolution
–
Overview of the key features ●
New built-in types
●
Scope and namespaces
●
Enumerations
●
Dynamic memory: new and delete
●
Smart pointers: unique_ptr, shared_ptr, weak_ptr
●
Error handling with exceptions
●
References
●
The const modifier
6
Introduction to C++ History and evolution –
Creator: Bjarne Stroustrup 1983
–
Standards: ●
The first C++ standard – –
●
1998 (C++98, major) 2003 (C++03, minor)
The second C++ standard – –
2011 (C++11, major) – significant improvements in language and library 2014 (C++14, minor)
7
Introduction to C+ History and evolution –
source: https://isocpp.org/std/status
8
Introduction to C++ Standard library –
C++ standard library = C standard library + STL (Standard Template Library)
–
STL – designed by Alexander Stepanov, provides: ● ● ●
Containers: list, vector, set, map … Iterators Algorithms: search, sort, …
9
Introduction to C++ Philosophy –
Statically typed
–
General purpose
–
Efficient
–
Supports multiple programming styles: ● ● ●
Procedural programming Object-oriented programming Generic programming
10
Introduction to C++ Portability –
Recompilation without making changes in the source code means portability.
–
Hardware specific programs are usually not portable.
11
Introduction to C++ Creating a program –
Use a text editor to write a program and save it in a file → source code
–
Compile the source code (compiler is a program that translates the source code to machine language) → object code
–
Link the object code with additional code (libraries) → executable code
12
Introduction to C++ Creating a program (using GNU C++ compiler, Unix) –
Source code: hello.cpp
–
Compile: g++ -c hello.cpp ●
–
Compile + Link: g++ hello.cpp ●
–
Output: hello.o (object code) Output: a.out (executable code)
C++ 2011: g++ hello.cpp -std=c++0x
13
Introduction to C++ The first C++ program
One-line comment
//hello.cpp #include using namespace std; int main(){ cout