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).

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:

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

Books

Online References

Software

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

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

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):

  1. On the Tools menu, choose Import and Export Settings
  2. In the dialog, click Import selected environment settings and then click Next.
  3. You can then save your current settings, but that's not necessary.
  4. 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):

  1. Open the project's Property Pages dialog box.
  2. Click the Linker folder.
  3. Click the General property page.
  4. 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):

  1. On the Tools menu, click Options.
  2. In the Options dialog box, open the Debugging node, and select the Edit and Continue category.
  3. To disable, clear the check box.
  4. 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):

  1. In Solution Explorer, right-click on the solution (root item of the tree) and select Add and New Project.
  2. 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:

  1. Open the project's Property Pages dialog box.
  2. Click the Linker folder.
  3. Click the System property page.
  4. 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.