Posts Tagged ‘function’

Functors in C++

Posted: 12th June 2013 by Tim in C++
Tags: , , , , , , ,

One neat feature of C++ is Functors, or function objects. Essentially, functors are just like normal objects, but they can be ‘called’ like any other function; they can take any number of arguments of any type and return a value of any type. However, because functors are objects, they can have state (without resorting to […]

Running C++ code from a C program

Posted: 11th April 2013 by Tim in C, C++
Tags: , , , , , , , ,

There are times where you have a C program but would like to call code written in C++. This is quite easy to do, and if done right will work on all (compliant) compilers on multiple platforms. To achieve this, you need to declare your function(s) to look like C functions in a header file. […]

When writing a math definition of a function, for example, the function may have different results depending on the value of the inputs. These are called cases and are grouped together with a large left curly brace. If you’re trying to typeset this in LaTeX, the cases environment makes this nice and easy. It’s easiest […]

Gnuplot is a great tool for creating plots. LaTeX is a great tool for creating documents. Both are (or at least can be) created using a text editor and compiling the source. Both work with Windows, linux/unix and Mac. Wouldn’t it be great if you could include a gnuplot plot in a LaTeX document without […]

For various reasons, you cannot create a pthread on an object’s function. There is, however, a few ways to get around that. One of the most flexible ways of doing this is to create a wrapper function to call an object’s method, taking a pointer to the object as an argument. For example, if you […]