C++ can be a strange language. Most of the time it’s easy to work with, but occasionally you’ll get errors which take forever to debug. Take a look at the following code and write down what you think the output will be. #include <iostream> class Base { public: virtual void test(int x = 0) { [...]
Posts Tagged ‘call’
C++ Gotcha – derived function default value
Posted: 13th December 2010 by Tim in C++Tags: argument, C, call, class, code, derived, functon, gotcha, inheritance, object, pointer, programming
0
Nanosleep in C / C++
Posted: 29th September 2009 by Tim in C, C++Tags: C, call, coding, development, nanosleep, programming, sleep, software engineering, usleep
usleep is not a very accurate form of sleep in C / C++. From the man page: The sleep may be lengthened slightly by any system activity or by the time spent processing the call or by the granularity of system timers. nanosleep, on the other hand, is much more accurate. The following code will [...]
Calling object functions in C++ with pthreads
Posted: 13th July 2009 by Tim in C++Tags: C, call, class, coding, function, programming, pthreads, Software Development, software engineering
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 [...]