Grundkurs i C++, för Java programmerare

Java designades som en slags förenklad C++. Det är lätt att låta sig förledas av likheterna i syntaxen. Dessvärre finns det många fallgropar att falla i för Java programmerare, eftersom vissa saker ser lika ut men fungerar på ett fundamentalt annorlunda sätt. Denna grundkurs riktar sig till rutinerade Java programmerare, som på snabbast tänkbara sätt vill börja med programutveckling i C++. Vi använder konsekvent Java som referensram och illustrerar likheter och pekar på skillnader. Självklart använder vi modern C++, vilket innebär C++17, ett modernt designperspektiv och frekvent användning av standardbiblioteket.

Grundkurs i C++, för Java programmerare
4 dagar
Beginner
Rutinerade Java programmerare
Kunna programmera i Java
  • GNU C++ Compiler
  • Jetbrains CLion
  • Ubuntu Linux
Här ser du vilka kursdatum som är tillgängliga. Klicka på en av datumknapparna för att anmäla dig till ett kurstillfälle. På kursen pratar läraren svenska, medan vårt kursmaterial alltid är författat på engelska.

Du sitter bekvämt framför datorn och deltar i kursen via internet. Vi använder programvaran Zoom för alla våra fjärrkurser.

I priset ingår kursmaterial som PDF.

Pris: 20 000 kr + MOMS/VAT (25%)

Du sitter bekvämt i ett av våra klassrum, vilka finns centralt placerade i Stockholms innerstad (Östermalmstorg).

I priset ingår tryckt kursmaterial (och som PDF), samt kaffe/te med smörgås på förmiddagen och kaffe/te med bulle på eftermiddagen.

Pris: 25 000 kr + MOMS/VAT (25%)

Om ni är tre eller fler personer från samma företags, kan ni beställa en företagsanpassad kurs. Då håller vi kursen på ett datum som passar er. Antingen på plats i era lokaler eller som en fjärrkurs. Vi kan även mixa fjärr- och klassrumskurs, om några av er önskar delta på distans medan resten föredrar att ses på plats.

Företagsanpassad Kurs

Här är ett sammandrag av vad du får lära dig på kursen.

  • Understand how C ++ differs from Java, e.g. pointers / references, copy designers and destroyers
  • Programming in Modern C ++
  • Use the standard library efficiently
  • Design your own data types
  • Understand and apply insights regarding memory management in C ++
  • Use auto (automatic type inference) almost always
  • Use lambda expressions to improve and simplify your code
  • Use std::string object productively
  • Work with STL containers, iterators and algorithms
  • Work file I/O and within the file system
  • Understand how to use and implement template based functions and classes
  • Understand how to use operator overloading
  • Understand when to use derived classes and virtual functions

Background and Overview

  • From cfront, Classic C++ and into Modern C++
  • Design objectives
  • Some myths and facts of C++
  • Language evolution
  • The concept Modern C++
  • Syntax summary
  • Simple compilation
  • C++ reference

Similarities with Java

  • Data types
  • Duck-typing in C++ or how to use auto
  • Expressions
  • Statements
  • Function declarations and function calls
  • Uses of namespaces, instead of packages and how it differs

Differences to Java

  • Organization of compilation units
  • Data areas and life-cycles
  • Global data in the data area
  • Local data in the stack area
  • Dynamic data in the heap
  • How to act in the absence of a garbage-collector?
  • Include is not the same as import
  • Taking advantage of the pre-processor (CPP)
  • The merit of inlining
  • An executable JAR file, is not the same as a compiled C++ program. How do you build apps in C++?

Pointers and references

  • Pointer declarations
  • Dereferencing operator
  • Address operator
  • Pointer arithmetics
  • Dangling pointers
  • The illusion of arrays
  • Nativ text strings and the danger of using them
  • Pointers to struct/class objects
  • Function pointers
  • References
  • Call-by reference
  • Return by-reference
  • What is move semantics
  • Rvalue references

Lambda Expressions

  • Lambda syntax
  • Passing free variables by reference or value
  • Functions taking lambdas as parameters and/or returning lambdas

Text Strings and Regexes

  • Why using std::string instead of nativ strings
  • Overview of std::string and its functions/operators
  • What is SSO (Short String Optimization) and how it is used
  • Working with legacy strings
  • Character oriented functions
  • Multi-line string literals
  • What is a regex
  • The regex support in modern C++
  • Matching text data to patterns
  • Searching using patterns
  • Replacing text fragments using patterns
  • Using regex iterators
  • Typical use cases
  • Splitting and joining strings

I/O Streams and Files

  • ostream / ofstream / ostringStream
  • istream / ifstream / istringstream
  • Bi-directional I/O with fstream
  • Manipulators
  • The input idiom
  • Line-oriented input
  • Word-oriented input
  • Character-oriented input

Helper Types

  • Pair
  • Tuple
  • Date-times
  • Durations
  • Clocks
  • Date formatting
  • Random number generators

STL Container Types

  • Sequence containers and typical methods
  • vector / dequeue / array
  • list / forward_list
  • Associative containers
  • Tree vs. hash implementations
  • Unique vs. multi-key versions
  • set / unordered_set
  • map / unordered_map
  • Container adapters

STL Iterators and Intervals

  • What is an iterator
  • What is a range and how is it used
  • Iterator categories
  • I/O iterators
  • End-point adapter functions

STL Algorithms

  • What is a std::* algorithm
  • The STL architecture
  • How to pass the business logic into algorithm functions
  • Understanding *_n and *_if suffixes of functions
  • Using functions with predicates
  • Using back_inserter iterators
  • Transforming and aggregating
  • Sorting
  • Populating data into containers

Classes (User Defined Types)

  • What is a user-defined type
  • Specification vs. implementation
  • Member variables and functions
  • Object creation (instantiation)
  • Visibility
  • Constructors
  • Destructor
  • Inline member functions
  • Member overloading
  • The pointer this

Class Member Forms

  • Class variables and functions
  • Member references
  • Read-only variables
  • Const marked functions
  • Inner classes and they differ to ditto in Java
  • Friend declarations

Constructors and Destructors

  • Initialization
  • Default constructor
  • Destructor
  • Copy constructor
  • Assignment operator
  • Pitfalls
  • Standardized class form
  • Enforcing compiler-generated members
  • Deleting compiler-generated members
  • Type conversion constructor
  • Type conversion operator
  • What is move semantics
  • Move constructor
  • Move assignment operator

Heap Allocated Objects

  • What is dynamic memory anyway
  • Using the new and delete operators
  • Pitfalls
  • The placement variant of new

Exceptions

  • What is an exception
  • Throwing exceptions
  • Catching exceptions
  • The merits of automatic destruction during throw
  • Exceptions in the standard library
  • Pitfalls

Templates

  • What is a template
  • Function templates
  • Class Templates
  • Member function templates
  • Template parameter forms
  • Type equivalence
  • Template specialization
  • Pitfalls
  • Type traits
  • Using decltype()
  • Variadic templates

Operator Overloading

  • What is overloading operators
  • Syntax
  • Overloadable operators
  • Rule set
  • Overloading of arithmetic operators
  • Overloading of relational operators
  • Overloading of I/O operators
  • Overloading of ++/– operators
  • Overloading of the index operator
  • Overloading of the arrow operator
  • Overloading of the function-call operator

Inheritance and Virtual Functions

  • Why do I inherit in C++, but extend in Java
  • Syntax
  • Protected visibility
  • There is no such thing as package visibility in C++
  • Invocation of super-class members
  • References and pointers of root class type
  • Performing down-casts using dynamic_cast
  • Constructor initialization order
  • Base class visibility
  • Virtual member functions and why they are important
  • What is the key difference between virtual methods and non-virtual methods in C++ and how do they compare to Java
  • How do I make a class and/or method abstract in C++
  • Use of override and final specifiers
  • Multiple inheritance and why you need to be careful
  • Implementing Java-style interfaces in C++

The Pre-Processor

  • Include files
  • CPP constants
  • Pre-defined constants
  • Conditional compilation
  • Include guards
  • CPP macro functions
  • Stringification and name catenation
  • Assertions

Building C++ Applications

  • Compilation steps
  • What is an abstract syntax tree (AST)
  • The assembler
  • Inline assembly code
  • The linker
  • Name mangling of C++ names
  • Inspecting the linker symbol table
  • The loader
  • Tracing executions
  • Compiler flags for warnings
  • Compiler flags for optimizations
  • Compiler flags for debugging
  • Creating a static archive file
  • Creating a dynamic linked library

Build Tools and Open-Source Libraries

  • Make
  • GNU Autotools
  • Premake
  • CMake
  • Gradle
  • Doxygen
  • Google Test
  • Catch2
  • log4cxx
  • Boost

Standards and Guidelines

  • Tracking the standard
  • Tracking compilers and what they support
  • Online compilers
  • The big C++ conference (cppcon)
  • The C++ Core Guidelines
  • GSL - The Guidelines Support Library