Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Intro to C++ - language
1. C++
-‐
for
Java
Developers:
Intro
to
C++
Jussi
Pohjolainen
Tampere
University
of
Applied
Sciences
2. C++
• 1998
ANSI/ISO
Standard:
– Core
language
– Standard
Library
• Many
C++
libraries
exist
that
are
not
part
of
the
standard
• New
standard:
ISO/IEC:2011
C++11
3. C++
Standard
Library
• Containers
– array,
bitset,
deque,
forward_list,
list,
…
vector
• General
– algorithm,
funcUonal,
iterator,
locale,
memory…
• Strings
– string
• Input
and
Output
– ios,
iostream,
ostream,
sstream..
• Numerics
– complex,numeric,
valarray
• Language
support
– excepUon,
limits,
new,
typeinfo
4. C
Standard
Library
• Macros,
typedefiniUons,
funcUons
for
tasks
like
string
handling,
mathemaUcal
computaUons,
memory
allocaUons..
• See:
– hYp://en.wikipedia.org/wiki/C_standard_library
8. GCC
Compiler
• The
GNU
Compiler
CollecUon
(GCC)
is
a
compiler
system
produced
by
the
GNU
Project
supporUng
various
programming
languages.
• C
(gcc),
C++
(g++),
ObjecUve-‐C
(gobjc),
Fortran
(gfortran),
Java
(gcj)
• CompaUble
IDEs
– Dev-‐C++
(Win),
NetBeans,
Eclipse,
QtCreator,
Xcode
9. Installing
• Ubuntu
– sudo
apt-‐get
install
g++
• Mac
OS
X
– Install
Xcode
and
install
command
line
tools
• Windows
– For
example
minGW:
hYp://sourceforge.net/
projects/mingw/
14. Code
Style
• Java
has
“standard”
for
code
style,
C++
does
not.
• Use
can
use
separate
apps
for
“preffy”
your
source
code
• For
example:
ArUsUc
Style
– hYp://astyle.sourceforge.net/
15.
16. Makefiles
• All
these
command
line
arguments
can
be
long
and
hard
to
write.
• Use
Make!
UUlity
that
automaUcally
builds
apps.
• hYp://en.wikipedia.org/wiki/Make_(sohware)
22. cout
for
output,
cin
for
input
• Output
– cout
<<
“hello!”;
• Input
– cin
>>
someVariable;
23. Datatypes
• Fundamental
types
– int,
short,
long
– float,
double,
long
double
– bool
– char
• Derived
types
– arrays,
pointers,
references..
• Class
types
– class,
struct,
union
24. const
and
enum
// Like final in Java
const int NUMBER = 100;
// Using enums
enum DAY { MON = 1, TUE, WED, THU, FRI,
SAT, SUN };
DAY today = MON;
25. CondiUons
in
C++
int a = 0;
if(a = 0)
{
cout << “What the..” << endl;
}
26. Arrays
const int LENGTH = 5;
int numbers[LENGTH];
numbers[0] = 12;
numbers[1] = 88;
..
27. About
Strings
• C++
has
two
kind
of
Strings
– char
arrays
– string
–
class
28. C
type
strings
• char
myString[6]
=
“Jussi”;
• //
Why
6??
The
array
contains
now
Jussi0!
• char
myString[]
=
“Jussi”
29. cin.get
// Reads maxLength number of chars
// from the user
cin.get(myString, maxLength);
// This leaves user given enter ‘n’ to input
// stream, use cin.get again to get rid of
//it..