Table of Contents
Object-oriented Programming (Winter Term 2011/12)
Lecturer | Dr. Carsten Gutwenger |
Major | M.Sc. Automation & Robotics |
Course Number | 048014 |
Semester | First |
Type / SWS / CP | Lab course / 3 SWS / 3 CP |
Language | English |
I will publish news about this course (e.g. new stuff on the web site etc.) in my Google+ stream, shared with a particular circle of mine. If you want to follow this stream, I need to add you to this circle (otherwise you cannot see these news in your stream). Just send me an email.
Location and Time
The course takes place in the Retina pool, room P1-101-108b (Otto-Hahn-Str. 8).
- Group 1: Tuesday, 10:30-12:45
- Group 2: Tuesday, 13:30-15:45
In both groups Orwa Nassour will also be there as a tutor to help you.
Final Exam
The final exam takes place on January 31. Here you will find all relevant information:
- You are qualified for the final exam, if you have passed at least three exam sheets; no further registration is necessary (list of qualified students).
- The final exam takes place in the Retina pool at the usual times for the lecture. There will be two groups (A 10:30-12:30 and B 13:30-15:30). For the first group we will have both pool rooms (108a and 108b), therefore some students of the second group will have to come to the morning session; see the group assignment.
- The two groups will (of course) get different, but equally difficult exercises.
- You will have to show a student ID and a passport, so we can check who you are.
- You are only allowed to use the printed lecture slides (best print them 6 slides per page) and a pen. We will provide paper. No further material is allowed, in particular no hand-written notes, no solutions to assignment or exam sheets, or any other source code. No laptops, no mobile phones! Breaking these rules will be considered as cheating and result in failing the exam.
- The exercises will be similar as the tasks in the assignment and exam sheets, but of course not as complex, and they will not require to write so much code (e.g. parts of the code will be given).
The results of the final exam (Jan 31) can be found in this list. It shows the points per exercise (max. 1 point), the total points, and if you passed (at least 2 points) or failed. 70.6% have passed the exam (60 out of 85).
Here are the solutions to the final exams:
Second Attempt
The second attempt took place on March 30, 14:00, in Otto-Hahn-Str. 14, room 104.
Qualified are all students who were qualified for the first attempt and failed or did not appear. The relevant topics are the same as for the first attempt.
The results of the second attempt (Mar 30) can be found in this list. It shows the points per exercise (max. 1 point), the total points, and if you passed (at least 2 points) or failed. 61.1% have passed the exam (11 out of 18).
Group Assignment
Group 1 (10:30-12:45)
H. Ahmed | S. Al-Rubaye | M. Alsayegh | D. Alshare | M. A. S. Alvi |
T. C. Arslan | A. Asad | S. M. M. Azher | V. Bangalore Nagendra | B. Bilgin |
P. Broujerdi | P. Dank | M. U. Ehsan | M. Elsharkawy | M. E. Er |
A. A. Farook | Y. Fisiha | S. K. Gajjala | H. Harnal | M. E. M. Hassan |
M. M. Ihsan | M. H. Iqbal | S. S. Kulkarni | N. Liu | H. Mahadevaiah |
A. Martinez Garcia | M. K. Mehmood | T. Mehta | L. Migdadi | M. Mohammadi Parsa |
Z. Nazir | M. Nejati | A. Oster | H. Patel | S. Patel |
S. Qa´adan | M. A. Saeed | N. Schafer | S. Sutradhar | M. Taghavi |
A. Tatulea Codrean | B. Tor | S. T. Turesay | S. Wan | C. Yildiz |
C. You |
Group 2 (13:30-15:45)
A. Ahmad Yousuf | R. Aymaz | P. R. Bhat | S. Damodaran | D. Desai |
M. A. Galván Mendoza | S. Gopinathan Asari Sujatha | S. C. Govindasamy Ramamoorthy | V. Hariharan | A. Harur Manoharan |
V. Indalkar | R. Ismail | D. H. Jani | P. Khobkhun | A. Krishnaswamy Rangarajan |
W. Li | Y. Li | R. Marishettihally Basavarajappa | I. A. Marta | S. S. Mudda |
M. K. Murugaiah | M. Nandakumar | K. Narayanan | Q. Navid | M. Noman |
A. N. Patel | A. V. Patel | N. Patel | R. Patel | A. Pithadiya |
K. Radhakrishnan | B. Raja | S. Sandhu | V. Selvantarajan | N. Shaik |
P. Shen | S. Shete | M. R. Sukhadia | Y. Sun | S. Thennilapuram Subramanian |
V. Thota | A. Ul Jabbar | V. Vora |
Content
In this course, you will learn
- the programming language C++,
- the principles of object-oriented programming, and
- using a programming environment (Visual Studio) for writing C++ programs.
Suggested Reading and Web Links
Books
- Practical C++ Programming by Steve Oualline, 2nd edition, O'Reilly Media, 2003
accessible online only from within the TU Dortmund network
- C++ Primer by Stanley B. Lippman, Josée Lajoie, Barbara E. Moo, 4th edition, Addison-Wesley Professional, 2005
accessible online only from within the TU Dortmund network
- Exploring C++: The Programmer's Introduction to C++ by Ray Lischner, 1st edition, Apress, 2008
Online References
- C++ reference at cppreference.com
- Visual Studio 2008 (online documentation at MSDN)
Software
- Visual Studio C++ 2010 Express Edition
You can download and install Visual C++ 2010 Express for free and use it at home.
- Visual Studio via MSNDAA (Microsoft Developer Network Academic Alliance)
This page explains how to obtain MSDNAA software with your Retina pool account (unfortunately in German). Basically, you need to request the Student User Agreement here, which you then get by email, print it and sign it, and then go to room P1-E0-314. They will then activate your access on the software server, where you can download e.g. Visual Studio .iso images.
- MacOS users: If you just want to write C++ programs at home, you can use MacOS' own development environment XCode. In order to use Visual Studio on MacOS, you need to run it in a virtual machine.
Material
You will find here all the slides as well as assignment and exam sheets (including solutions for assignment sheets).
Lectures
No | Date | Topics | Slides | Source Code |
---|---|---|---|---|
1 | Oct 11 | Welcome and Organization | slides | |
Creation of pool accounts | ||||
“Hello World!” project | hello_world.cpp | |||
2 | Oct 18 | Variables and Simple Control Structures | slides | |
Variables and assignments | ||||
Printing and reading data | reading_data.cpp | |||
if-else statements, while-loops | printing_numbers.cpp | |||
3 | Oct 25 | Loops and Strings | slides | |
do-while- and for-loops | sum_up.cpp | |||
break and continue | ||||
C++ strings and the bool data type | ||||
Output formatting with manipulators | formatting_output.cpp | |||
4 | Nov 08 | Vectors and Scope | slides | |
Floating point numbers | printing_floats.cpp | |||
Increment and decrement operators | pre_vs_post.cpp | |||
C++ vectors | vectors.cpp fib_vectors.cpp sort_vector.cpp | |||
Scope and lifetime of variables | nested_scope.cpp | |||
5 | Nov 15 | File I/O and Maps | slides | |
File I/O and characters | reading_file.cpp writing_file.cpp | |||
C++ maps | maps.cpp | |||
Type definitions, constants | ||||
Types of integers and the sizeof operator | sizeof.cpp | |||
6 | Nov 22 | Functions and References | slides | |
Functions | power.cpp nested_calls.cpp flow_of_control.cpp | |||
References | swap.cpp print_vector.cpp | |||
switch statements | switch.cpp | |||
7 | Nov 29 | Function Overloading | slides | |
Type Conversion | ||||
Comma Operator | comma.cpp | |||
Function overloading | overloading_max.cpp overloading_print.cpp | |||
8 | Dec 06 | Custom Types | slides | |
Structures | ||||
Operator overloading | point.cpp | |||
9 | Dec 13 | Access Control and Inheritance | slides | |
public and private | ||||
Inheritance | employee.cpp | |||
Class Hierarchies | hierarchy.cpp | |||
10 | Dec 20 | Pointers and Polymorphism | slides | |
Constructors, destructors and assignment | ||||
Pointers | ||||
Virtual and pure virtual functions | redefine.cpp virtual.cpp draw.cpp | |||
11 | Jan 10 | Memory Management | slides | |
Static and global variables | static.cpp global.cpp | |||
Static data members | static_data_members.cpp | |||
Dynamic memory allocation | slist.cpp | |||
12 | Jan 17 | How to debug programs with Visual Studio | slides | |
13 | Jan 24 | Smart pointers and Function Objects | slides | |
Smart pointers | unique_ptr.cpp shared_ptr.cpp | |||
Function objects | functor.cpp sort.cpp is_odd.cpp |
For the topics we consider in the last two lectures, there was a voting on Google+.
Assignments
No | Date | Sheet | Additional Files and Solutions |
---|---|---|---|
1 | Oct 18 | sheet 01 | solution_1_1.cpp solution_1_2.cpp solution_1_3.cpp solution_1_4.cpp solution_1_5.cpp |
2 | Oct 25 | sheet 02 | solution_2_1.cpp solution_2_2.cpp solution_2_3.cpp |
3 | Nov 08 | sheet 03 | solution_3_1.cpp solution_3_2.cpp solution_3_3.cpp solution_3_4.cpp |
4 | Nov 15 | sheet 04 | desiredsignal.txt measuredsignal.txt words.txt grades.txt |
solution_4_1.cpp solution_4_2.cpp solution_4_3.cpp solution_4_4.cpp | |||
5 | Nov 22 | sheet 05 | solution_5_1.cpp solution_5_2.cpp solution_5_3.cpp |
6 | Nov 29 | sheet 06 | solution_6_1.cpp solution_6_2.cpp solution_6_3.cpp solution_6_4.cpp |
7 | Dec 06 | sheet 07 | solution_7_1.cpp solution_7_2.cpp exercise_7_3.zip |
8 | Dec 13 | sheet 08 | solution_8_1.cpp solution_8_2.cpp |
9 | Dec 20 | sheet 09 | solution_9_1.cpp solution_9_2.cpp solution_9_3.cpp |
10 | Jan 10 | sheet 10 | solution_10_1.cpp solution_10_2.cpp solution_10_3.cpp |
11 | Jan 17 | sheet 11 | |
12 | Jan 24 | sheet 12 |
Exam Sheets
No | Date | Due | Sheet | Solutions |
---|---|---|---|---|
1 | Oct 25 | Nov 08 | exam sheet 1 | |
2 | Nov 22 | Nov 29 | exam sheet 2 | |
3 | Dec 13 | Dec 20 | exam sheet 3 | exam_3_1.cpp exam_3_2.cpp exam_3_3.cpp |
4 | Jan 17 | Jan 24 | exam sheet 4 | exam_4_1.cpp exam_4_2.cpp exam_4_3.cpp |
- The current results of the exams (Jan 09).
You need 3 positive exams (≥ 3 in the last column) for being allowed to write the final exam.
Visual C++: Problems and Solutions
When using Visual Studio on the Retina pool computers, there are some problems occurring quite frequently. Here, I describe some of them along with solutions to fix them.
You did not choose "Visual C++ Development Settings" when starting Visual Studio for the first time
This might result in a setup of the development environment that is not the best for C++ projects. These settings affect many parts of the development environment, including window layout, menus, and shortcuts. In order to reset your current settings to the recommended “Visual C++ Development Settings”, proceed as follows (see also MSDN Help):
- On the Tools menu, choose Import and Export Settings
- In the dialog, click Import selected environment settings and then click Next.
- You can then save your current settings, but that's not necessary.
- Choose the “Visual C++ Development Settings” and proceed.
When you run your program from the Visual Studio environment, a strange warning concerning the path appears
This warning appears, when Visual Studio tries to set the current path to the directory in which your project lies. If this fails, this warning appears and the current path is set to some default (the Windows directory I guess). The program, however, is started and works fine. This warning message is annoying, but you only have a problem if, e.g, you want to load and store files and assume these files are located in your project directory (without using a full path name).
The source of this problem is that your home directory is mounted as a network share, and by default a path name starting with “//pool-server03.retina...”
is used as the directory, in which your project directory is placed. You can simply fix this problem by changing this path name when you create a project. Use the drive letter R: which refers to your home directory, so use a path name that starts with R:\Visual Studio 2008\Projects
.
When you start a program an error occurs since msvcr90d.dll could not be found
This error occurs occasionally, when you build your program in Debug configuration (which is the default). It does not occur in Release configuration.
The problem seems again be caused by the fact that home directories are mounted as network shares. A fix that seems to work is to disable incremental linking. You can do this as follows (see also MSDN Help):
- Open the project's Property Pages dialog box.
- Click the Linker folder.
- Click the General property page.
- Modify the Enable Incremental Linking property (set it to /INCREMENTAL:NO).
If you do this, you will get a warning when building your program which tells you that Edit and Continue is enabled but incremental linking is disabled. You can then switch off Edit and Continue as follows (see also MSDN Help):
- On the Tools menu, click Options.
- In the Options dialog box, open the Debugging node, and select the Edit and Continue category.
- To disable, clear the check box.
- Click OK.
Do I have to create a new project for every program / exercise?
When you work on an assignment / exam sheet, you have to write many little programs, so the question arises how to do this task with the least effort.
When you create a new project as explained in the first lecture, you actually will create a new solution with a new project. You can see all the items in the currently open solution with the solution explorer (showing an explorer-like tree-view). In fact you can have several projects (programs) within one solution, so there is no need to create a new solution for every little program. To add a new project to the currently open solution, proceed as follows (see also MSDN Help):
- In Solution Explorer, right-click on the solution (root item of the tree) and select Add and New Project.
- Proceed as usual for creating a new project (select project type and template, …)
Once you have several projects in a solution, you will realize that always one project is shown in bold face. This project is the program that will be started when you select Start or Start without Debugging from the menu. If you want to have a different project as start-up project, right click on the project and select Set as StartUp Project (see also MSDN Help).
You accidentally selected as project type Win32 Application
If you accidentally choose Win32 Application instead of Win32 Console Application as project type, you will get a compiler error about an undefined WinMain function. Instead of creating a whole new project, it suffices to change one linker option:
- Open the project's Property Pages dialog box.
- Click the Linker folder.
- Click the System property page.
- Modify the SubSystem property: set it to Console (/SUBSYSTEM:CONSOLE)).
If you use both Debug and Release configurations, you have to change it for both configurations.
Interesting Google+ Posts
My posts on Google+ about this course are marked with #cgOOP. You must be logged in to see the posts.
- Overloaded input and output operators for a
vector<int>
: vector_in_out.cpp
This input operator allows to enter the elements of the vector separated by whitespace and terminated by pressing return; the output operator simply prints the elements separated by a space character.
See also Google+ post.