Setup C++ courses


About the C/C++ course


The ANSI-C++ standard has standardized and extended the C++ language. Extensions to the language previously resulted in changes of setup of the C/C++ lectures. Currently we assume that your compiler supports standard C++20.

The original `introductory and advanced courses on the C/C++ language' were once converted into one single set of lectures, divided over three organizational units (the C++ course parts I, II and III). Attending only the first part is like walking on one leg. It barely gets you where you want to be. Part II targets what many consider to be the core elements of the language, and you should really try to attend this part. Part III is intended for those participants who are really interested in the language. To paraphrase Colin Fletcher (the Complete Walker, Knopf, 1978): it turns you from an insecure biped to a confident triped (p. 49).

In the Academic Year 2016-2017 the course's organization was significantly modified. In the past we made two important observations:

In the new course setup we've addressed the first item by compressing several initial lectures into one initial lecture, highlighting the very basic elements of the language. Even though we relaxed the compression somewhat at the start of the 2017-2018 Academic Year, participants not having any previous experience in programming are very welcome to join the course, but are also advised to read an introductory book on programming before the actual course starts.

In the Academic Year 2018-2019 we changed the way ratings for completed exercises are determined. See this file for a description.

Another important reason for reorganizing the course is of course the continuing growth of C++ as a language. Confronted with a choice to either extend the course with additional lectures or to compress the initial lectures into one, thus making room to cover new topics, we decided to slightly compress the course, allowing us to cover all aspects of the language in three standard blocks of eight lectures.


The Software


Participants are free to select the software they want to use during these courses. In particular: you're free to select your favorite compiler. However, not every compiler supports every part of the C++ standard equally well.

During this course using a developmental environment is discouraged as such an environment often results in a reduction of `insight' and easily lures you into questionable programming techniques.

Participants are advised to use the GNU g++ compiler, which is available on both Unix operating systems and Windows products. The GNU g++ compiler was developed within the context of the philosophy of the Free Software Foundation meaning (among other things) that everybody may download and use the software at no costs.

For this course you should use a recent GNU g++ compiler. No support can be given to students using a different compiler, and no rights can be derived from using compilers not adhering to or using less complete implementation standards than the GNU g++ compiler version 13.2.0 . Usually a slightly older version (e.g., the last minor-release of the previous major release) is acceptable, at least for the first part of the course.

How to install the GNU g++ compiler on Unix systems

Below the steps are described which could be taken to install the GNU g++ compiler on a Unix operating system:

Students attending the C/C++ should have installed the necessary software before the course's first lecture, as the compiler is going to be used right from the start.


C++


The C++ language is an elaborate language, consisting of seven main facets. Only two of these facets were already present in the C programming language, and then only partially.

C++ is also a beautiful language, showing features not commonly encountered in other languages:

Because of all this C++ is the language of choice for a large number of major software engineering projects. It may very well become your language of choice too.

Having learned C++ opens an easy road to an wide range of C-like languages (including C itself). Since C++ is a direct descendant of C, it is very well suited as a primary computer language, not requiring novices to plunge immediately into complex object oriented programming concepts, which are usually well beyond a novice's level of com- and apprehension.

The C++ course covers all seven facets of the C++ computer language. These facets are:

  1. The primary grammar: statements, expressions and operators which were (for the greater part) already available in C (but not all; some of C++'s additions are l- and r-value references; several new data types; strict use of const; range-based for loops; and lambda functions.
  2. The procedural part: the tools the language has to offer for top-down programming: functions etc.. But again there are extensions: C++ offering overloaded functions, default function arguments, fine-grained scoping-rules and the ability to reducing life-times to sensible blocks;
  3. The exception handling mechanism, obliterating the need for (local and non-local) goto's and unsafe exit() calls;
  4. Object-based programming: Classes, Operator overloading, Function objects: tools to construct objects helping us to solve programming problems in a far more natural way than offered by the (now traditional) top-down decomposition methods (without loosing all the benefits of those methods);
  5. Generic Algorithms: Generic Algorithms, implemented using templates, offer implementations of a wide range of commonly occuring programming problems, idependently of the actual data types on which the algorithms operate.
    Related to the generic algorithms: the Standard Template Library and the so-called Abstract Container Types are also covered.
  6. Object oriented programming: inheritance, polymorphism, virtual functions, class-hierarchies: methods to develop reusable software: software that can easily be extended, modified and reused in various situations in ways completely different from and vastly more powerful than offered by earlier paradigms. One of the more amazing features of object oriented programming being that software developed earlier in time may use characteristics of software developed later in time. Object oriented programming has shown its value in developing a standard set of design patterns when developing reusable software. These design patterns are also introduced and (partially) covered by the C++ course.
  7. The template mechanism itself: developing abstract `recipes' for both functions and classes which may then be used by the compiler to actually create new functions and classes based on these recipes. The compiler can do this without requiring the programmer to provide concrete implementations of these functions and classes. Templates are very important in current-day C++ programming, as all abstract containers and generic algorithms use templates. During the C++ course participants learn to develop their own templates, as well as a `feel' for the situations in which they may be used profitably.
    Templates not only allow the compiler to create code on-the-spot from recipes we've presented the compiler with, but it turns out that the template mechanism has allowed programmers to do things compile-time that were heretofore impossible to do. The aphorism never do run-time what you can do compile-time has left the level of a hollow phrase in C++ where it is possible to take full control of the compiler by actually programming it. This has resulted in remarkable results, like having the compiler generate series of prime numbers or completely changing memory allocation schemes in 10 seconds.

The three parts of the C++ course cover the various facets of the C++ in (loosely) the order mentioned above. In addition to the topics that are `purely' C++ several meta topics, like the use of tools for generating lexical scanner and parser classes are covered by the third part of the C++ course. These tools allow software engineers to design their own grammars and input languages.


The course's setup.


Part I:

During the first part of the C++ course we focus on the primary grammar: following the initial lectures, covering basic concepts like source code organization and layout; compilation vs. interpretation; using and designing software libraries, C++ expressions, statements and (free) functions are discussed. This opens the road to `procedural (structured) programming'.

At this point we're ready to introduce `Object Based Programming', introducing classes, objects, construction, and composition.

C++ introduces, different from C's FILE-based input/output (I/O) stream-based I/O. Stream-based I/O is closely related to object oriented programming, but it can be em(used) before those latter concepts are well introduced. Having covered the basics of object based programming the course moves to an in-depth coverage of stream-based I/O.

C++ shares facilities for memory allocation with C (albeit that C++ adds many more features to those offered by C). By the end of part I arrays and pointers, including fundamental forms of memory allocation, among which placement new has been covered.

Students who completed part I of the C++ course are able to

This part's actual topics are listed in this part's schedule.

Part II:

In this part Object Based and Object Oriented programming are the main topics. Continuing where the first course ended, the ins and outs of classes are covered. This eventually results in programs in which design patterns and other advanced methods to construct software may be used.

Many C++ programs heavily use templates: abstract containers, allowing the software engineer to construct complex data structures with little effort. These containers are also covered during this part. The actual use of generic algorithms and the construction of templates is not covered in this part of the course.

Students who completed part II of the C++ course are able to

This part's actual topics are listed in this part's schedule.

Part III:

This part of the course aims at advanced (but important and frequently used, make no mistakes about this) topics of the C++ programming language. Also, tools for generating lexical scanner and parser classes are introduced and used.

Students who completed part III of the C++ course are able to

This part's actual topics are listed in this part's schedule.

Exercises and training


For all three parts ample means are provided to gain mastery of the C++ language. We use an electronic mailing list, the lecturers may be contacted (even outside standard office hours), and many exercises are presented, which must be completed within a limited period of time. This ensures constant exposure to the language, which has beneficial learning effects.

If you're interested in the C/C++ language you're more than welcome to join and attend the C++ course. Contact the lecturer if you have any questions about this course ( Jurjen Bokma (phone (+31 50 363 9253))).


Frank B. Brokken (f.b.brokken@rug.nl)
15 November 2021