is this main program right to this class?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tamara omar
    New Member
    • Sep 2006
    • 23

    is this main program right to this class?

    i want u to check this main program if it is right? plz

    Enum error_code{over flow,under flow,success};
    Const int maxstack=100;
    Template<class stacktype>
    Class stack{
    Private:
    Stacktype entry [maxstack];
    int count;
    public:
    stack();
    error_code push(const stacktype & item);
    erroe_code pop();
    eror_code top(stacktype &item) const;
    bool empty() const;
    bool full() const;
    void clear();
    int size() const;
    };
    Template<class stacktype>
    Error_code stack<stacktype >::push(const stacktype &item)
    {if (full())
    Return overflow;
    Entry[count]=item;
    Count++;
    Return success;
    }
    Template<class stacktype>
    Error_code stack<stacktype >::top(stacktyp e &item) const
    {
    if (empty())
    Return underflow;
    Entry[count-1]=item;
    Return success;
    }
    Template<class stacktype>
    Error_code stack<stacktype >::pop( )
    {
    if (empty())
    Return underflow;
    Count--;
    Return success;
    }

    Void main()
    {stack<int> obj;
    Obj.push("john" );
    Obj.push("sarah ");
    If (obj.push("mala k")!=success )
    {
    Cout<<"problem" <<endl;
    Exit(1);
    }
    Obj.pop();
    Temp="salam";
    Obj.top(temp);
    Cout<<temp<<end l;
    }//end of main
  • willakawill
    Top Contributor
    • Oct 2006
    • 1646

    #2
    Originally posted by tamara omar
    i want u to check this main program if it is right? plz
    Hi does it do what you want it to do?

    Comment

    Working...