• C programming

  • What is a Ctor?

    If we define a member function in a class without specifying its return value, we get a warning which reads as ” (name of function) member function definition looks like a ctor, but name does not match enclosing class”. This is a pretty confusing warning. Actually the meaning of the warning is pretty straight. ctor [...]

  • When should we use recursion and when should we avoid it?

    Recursion is less efficient than a loop. Therefore use a loop instead of recursion whenever you can. Recursion usually helps create cleaner code. Therefore use recursion when clarity is needed more than efficiency. Consider the following example, which calculates the nth term in the Fibbonacci series. The recursive function calls itself 21,890 times to calculate [...]

  • What will be the output of following Program ?

    #include <iostream.h>
    class base
    {
    public :
    f( )
    {
    f1( ) ;
    }
    void f1( )
    {
    cout << “base” ;
    }
    } ;
    class der : public base
    {
    public :
    void f1( )
    {
    cout << “derived” ;
    }
    } ;
    void main( )
    {
    der d ;
    d.f( ) ;
    }
    Output of this program will be “base”. This is because the statement
    der.f( )
    will call base class’s f( ) function. In f( ) we have called f1( [...]

  • More from C programming
  • Tutorial

  • Thread Synchronization: Using Events Signaling

    In the last articles we saw how to synchronize two threads using critical section and mutex. They allow both the threads to execute at the same time. But only one thread can access the blocking object at a time. However, sometimes we may wish to write two threads where one thread should not get executed [...]

  • Thread Synchronization : Using Mutex Objects

    Download source code for this project here Thread Synchronization Using Mutex
    The word mutex comes from mutually and exclusive. Mutexe is used to gain exclusive access to a resource mutually shared by two or more threads. Unlike critical sections, mutexes can be used to synchronize threads running in the same process or in different processes. There [...]

  • Thread Synchronization : Using Critical Section

    Thread Synchronization : Using Critical Section

    Download source code for this project from here Using Critical Section
    Software development is a team effort. Unless team members cooperate with one another, synchronize their work with the rest of the team, the team can’t go far. Similarly if in a program there are several threads running, unless their activities are synchronized with one another [...]

  • More from Tutorial