e-x-a.org » NPRG041 C++ programming (en)

Small infopage about the C++ lab of NPRG041.

  • Taught by: Miroslav Kratochvil, in case of questions contact exa.exa@gmail.com
  • Meeting point: MS MFF, SW1, every Thursday at 17:20. 2015/16.

Abnormalities

  • I teach first two english lectures instead of David Bednarek (15:40 in S11, just before the lab).
  • Exact requirements for getting the credit/exam for Erasmus students will be specified on the third lecture.

Homework

Students should create a nice library for handling matrices of real (float) numbers. It should support basic matrix operations and inversion. Demonstration code should load the matrices from two text files (that may have empty or incomplete rows, in that case the space is assumed to be zero), do something interesting with them, and save the result to third file. Simple multiplication is good, but linear equation system solving makes a much more useful demo.

Do not implement the Strassen multiplication, naive O(n^3) method is OK.

Solution should follow good C++ programming standards:

  • usage of correct design patterns (so the users can use it just like STL containers)
  • separation into interface (.hpp) and library (.cpp) part (look at how other libraries do it)
  • memory safety (so it won’t crash)
  • resource efficiency (i.e. loading should only read the file once (no seeking) and the matrix data should not be reallocated during loading, so that loading runs in O(filesize)))
  • meta-properties like code readability, culture, modularity, transparency, etc.

Homework is due by 1.1.2016.

Project

Every student should create an individual project and submit it to get the credit. Topic is variable, but should be discussed and agreed upon before the end of November. Size of the project is not an issue, but at least around 1000 lines of (condensed and neat) code is a good guideline.

Erasmus students may need a completely different time limits, if you are from Erasmus, contact us for details.

Bad topics:

  • Boring libraries
  • Boring games
  • Anything that does not behave C++-ish (e.g. code without a single class construction)
  • Anything that requires complicated or very specific user interface (e.g. bank account simulator, unless the interface is solved neatly in some novelty C++ way)
  • Anything that has 100000 implementations already hanging around the internet
  • Also, there’s already too many of checkers, worms, tetris, pacman, snake, tictactoe, etc.

Good topics:

  • Small fast games (fun!)
  • Convenient data structures with demos (useful!)
  • Physics-like simulations of something (collisions etc. are cool)

Timeline

2015/10/08

Crash course into the wonders of C++. Sorry for the slow and chaotic start, next time I’ll have space to get prepared. Basic stuff about how C/C++ works with some examples.

2015/10/15
  • Lecture: All the stuff I skipped/forgot at the first one — real reasons for low-level programming, overloading, the rest about pointers, l/r-values, basic allocation, ...
  • Lab: Handling MSVC++, some practical examples (sieving primes, mergesort, complex class done by hand)
2015/10/22
  • Lecture: held by David Bednarek from now on.
  • Lab: A word (of caution) about preprocessor. Usage of the most useful parts of the standard library, continuing with file i/o, sets, maps, multiset/map variants, shared pointers.
2015/10/29
2015/11/05
2015/11/12
  • Not much. Word about how to compile/link stuff by hand. Remember that all members of the class have to be declared in class definition (in class xxx { ... };, binary interface of the class would be incomplete otherwise).
2015/11/19
2015/11/26
  • cancelled due to another event taking place
2015/12/03
2015/12/10
  • coding a set-like container by hand, i.e. Fun With Pointers, Lots Of Them — using splay trees for simplicity. Supports iterators, but adding more STL-compatible machinery is a good exercise.
2015/12/17

Practical stuff

2015/01/07 (next time)
  • practical approach to const
  • virtual machines (warmup for the final test)
2015/01/14 (last time)
  • text algorithms (warmup for the final test vol. 2)

Bonus stuff

  • English slides for the lecture! (beta)
  • I was asked whether we will do any graphically shiny stuff at the lab. That looks like a good demonstration of C++ powers, so some of the last seminars will be about interfacing with graphical APIs.