Oct 10, 2013 ... C++: How to Program, H.M. Deitel and P.J. Deitel, 5th edition (Prentice. Hall,
2005) ... C++ are the most widely used programming languages for.
CE221 Programming in C++ Part 1 Introduction 10/10/2016
CE221 Part 1
1
Module Schedule There are two lectures (Tuesday 13.00-13.50 and Thursday 9.00-9.50) each week in the autumn term, and a 2-hour lab at either 15.00 on Thursdays or 9.00 on Fridays. (Note that the labs start in week 3 – there are none in week 2). There will also be two revision lectures in the summer term.
10/10/2016
CE221 Part 1
2
Assessment One two-hour examination in May/June (60% of the module credit) Two programming assignments to be submitted by lunchtime on Monday of week 8 and Wednesday of week 16 (20% each) You will be required to demonstrate your submitted programs for the first assignment in the lab in week 8 or 9. (Note that this module has no week 6 test.)
10/10/2016
CE221 Part 1
3
Recommended Reading The main recommended text for this module is Thinking in C++, B. Eckel, Volume 1, 2nd edition (Prentice Hall, 2000)
available for free download at http://www.agitate.org.uk/eckel
Alternative books include C++: How to Program, H.M. Deitel and P.J. Deitel, 5th edition (Prentice Hall, 2005) C++ for Java Programmers, T. Budd (Addison Wesley, 1999),
and the definitive reference The C++ Programming Language, B. Stroustrup, 3rd edition (Addison Wesley, 2000) . 10/10/2016
CE221 Part 1
4
Motivation for Learning C++ C++ is more powerful and efficient than other high-level programming languages (although more complicated). C and C++ are the most widely used programming languages for robotics and games, and for writing compilers and operating systems and drivers of hardware devices. Consequently a knowledge of C++ is a big advantage in the jobs market.
10/10/2016
CE221 Part 1
5
Learning Outcomes After completing this module, students will be expected to be able to
explain the basic concepts and features of C++.
describe the underlying memory model and explain the role of the execution stack and the heap.
write object-oriented programs that incorporate basic C++ features such as pointers, references, inheritance, function overriding, operator overloading, exceptions, etc.
make effective use of the C++ Standard Template Library.
10/10/2016
CE221 Part 1
6
Lecture Outline The lectures for this module are divided into three main parts:
Basics: fundamental types and variables, memory management, references, pointers, arrays, control structures, functions, classes and objects, operator overloading, an Array class, the string class, file processing, comparison of C++ and Java.
Libraries: templates (function templates and class templates), containers, iterators, algorithms, the Standard Template Library (STL).
Advanced topics: inheritance, polymorphism, exception handling.
10/10/2016
CE221 Part 1
7
C++ Development Environments Development of a C++ program involves six phases: edit, preprocess, compile, link, load,
Disk
execute.
Memory CPU
Popular IDEs include Borland C++, Visual C++, MFC. However, in the labs we shall be using TextPad. 10/10/2016
CE221 Part 1
8
“Hello World” in Java, C and C++ 1 // Java public class HelloWorld { public static void main(String args[]) { System.out.print("\nHello, World!\n"); } } /* C */ #include /* could use int main() */ main() /* default return type is int */ { printf("\nHello, World!\n"); }
10/10/2016
CE221 Part 1
9
“Hello World” in Java, C and C++ 2 // C++ #include // using namespace std;
// could use int main(int argc, char* argv[]) or // int main(int argc, char* argv[], char **env) main() // default return type is int { // cout