Jan 142013
 

How will you find the size of a structure in C/C++ language without using sizeof operator.

(Note: sum of sizes of all fields of a structure may not be equal to the exact memory allocated to the structure. See, Method-1 in solution). Continue reading »

vliegen123.nl

Sep 032012
 

In C++, a struct can have functions also, the way we have in a class. For example, the below definition of Node in C++ is perfectly valid.

struct Node
{
  private:
    int data;
    Node *link;

  public:
    // Default Constructor
    Node():data(0), link(NULL)
    {
        cout<< " Default Constructor";
    }

    // Single Argument Constructor
    Node(int d):data(d), link(NULL)
    {
        cout<< " Single Argument Constructor";
    }
};

What is the difference between the two ?
Continue reading »