Edgar Huckert: C++ samples

Sometimes friends ask me for help with C++ problems. I start therefor here a small collection of sample files for C++. The files are not very ambitious and should be compilable with any C++/Rev11 compiler.

Some STL samples dealing with containers may be found here.

Objects, pointers and derivation

This C++ sample file explains how derivation(inheritance) works. It also shows the use of classes, class instances and pointers to class instances. A basic knowledge about pointers in Standard C is needed. Virtual functions are also illustrated.

Complex numbers

In contrast to other programming languages like D C++ does not implement complex numbers in the language but in the STL library. The class complex is a templated class, i.e. it must be specified as complex<double> or complex<float>.

This C++ sample file shows how complex numbers can be handled in C++. Depending on the age of you compiler you have to play with the compile-time option "-std=". See the source code for comments. Some compilers do not follow completely the last conventions for complex numbers. Depending on the compiler you also have to play with naming conventions.


Copyright for all images, texts and software on this page: Dr. E. Huckert

Contact

If you want to contact me: this is my mail address