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.

Generate DLLs, access functions in DLLs

DLLs correspond under Windows (more or less) to shared libraries in other operating systems. Here are two programs (sources) written in standard C++ under Windows 32 Bit:

The DLLs I mention here are object DLLs, not ressource DLLs. Both programs are console programs - no GUI here. I testted the programs with the Digital Mars C++ compiler- they should run however also with other C++ compilers. Hints for compilation, linking and usage are in the source files.


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