C++

C++ objects and Stack


Stack is heart of software. Without stack, software cannot exist or software cannot exist without stack. The most ultimate concept is stack in software engineering but text book stack is waste and no use at all. 


This is very simple C++ program but there are lot need to understand behind.






#include


class Addition
{
        int a,b;


public:
       void setXandY(int x, int y)
       {
        a = x;
        b = y;
       }


        int add()
        {
                return a + b;
        }
};


class subtraction
{
        int a,b;


public:


        void setXandY(int x, int y)
        {
                a = x;
                b = y;
        }


        int sub()
        {
                return a - b;
        }
};


main()
{
        Addition addObj;


        addObj.setXandY(20, 10);


        subtraction *subObj =(subtraction *) (void *)&addObj;


        cout<sub();
}




Language of organizing data is data structure, Stack is one of the ultimate data structure in software evolution.