G52CPP C++ Programming: DR Jason Atkin
G52CPP C++ Programming: DR Jason Atkin
C++ Programming
Lecture 1
Dr Jason Atkin
This Lecture
Pre-requisites
Module Aims and Information
History of C and C++
Module Structure and Assessment
Why Learn C and C++
What is C++ (vs Java?)
Suggested Course Texts
C++ Hello World (vs C Hello World)
2
Pre-requisites
Procedural C Programming
You should already know a fair amount about C
programming
You should understand a considerable number of C
functions
You will understand more by the time you finish this
module
Module Information
All information is available on the moodle
web page:
http://moodle.nottingham.ac.uk/course/view.
php?id=36352
Including:
Lecture slides (drafts a day or so before lectures)
Code samples (when relevant)
Lab notes (as they are released)
Coursework information (later)
Revision information (later)
My Module Aims
Understand and write C++ source code
This is a PROGRAMMING module
Understand what your code actually does
Know something of how C++ implements features
You are using C/C++ for the speed (otherwise choose an
easier language) so understand the issues
We will see:
The similarities and differences between C, C++ and Java (& why)
The C++ basics the most commonly used features
What advanced features exist, to look them up if needed
11
Cross-platform compilation
Compared with Assembly code, but not as much as Java
14
15
Module Structure
16
Organisation
17
Feedback
19
Feedback
Assessment
21
C++ vs Java?
(A comparison, not a contest)
25
What is C++?
Procedural C
Global Functions
File-specific functions
Structs
Pointers (addresses)
Low-level memory access
C Preprocessor
Variables
Arrays
Loops
Conditionals
Function Libraries
Standard functions
Custom libraries
O/S functions
Classes
- Grouping of related data together
- With associated methods (functions)
new for object creation
delete for object destruction
Constructors, Destructors
Operator Overloading
Assignment operators
Conversion operators
Inheritance (sub-classing)
Virtual functions & polymorphism
Access control (private/public/protected)
Templates
(Generic classes)
Non-C features
e.g. References
Class Libraries
(+templated classes)
Standard library (much C++11)
BOOST (beta libraries?)
Platform specific libraries 26
Classes
- Grouping of related data together
- With associated methods (functions)
new for object creation
delete for object destruction
Constructors, Destructors
Operator Overloading
Assignment operators
Conversion operators (toString()?)
Inheritance (sub-classing)
(ONLY) Virtual functions & polymorphism
Access control (private/public/protected)
Templates
Generics (weaker)
Non-C features
(ONLY) references
Class Libraries
(Generics ~ C++ templates)
Collections
Networking, Threading, etc
Graphics - standardised 27
Java:
Do it my way and Ill do more of the work for you
But it may be less efficient than doing it yourself
Some things cannot be done in Java alone (JNI)
Course Text?
32
Semi-recommended text
The Complete Reference: C++, Fourth Edition
by Herbert Schildt
Similar structure to this module (C then C++)
A reference, not a tutorial!
(Images courtesy
of amazon, but
books are available
from many places)
33
You are better off using the time to try coding though!
Hello World
A simple C++ (and C) program
36
C version
C++ version
37
Next lecture
C and C++ similarities and
differences
Practical demos ensuring that you
understand key C/C++ elements
May go beyond what you already know