my program is
class stack
{
protected:
int tos;
int store[10];
stack()
{
tos = 0;
}
public:
void push(int x);
int pop();
};
void stack::push(int x)
{
cout<<"put the values into stack";
store[tos++] = x;
}
int stack::pop()
{
cout<<" get the values from stack ";
return store[--tos];
}
main()
{
stack stk;
int i;
for(i=0;i<=9;i++)
{
stk.push(i+10);
}
for(i=0;i<=9;i++)
{
cout<<stk.pop();
}
getch();
}
here int store[10] array only store 10 items only. I want another class that inherits from stack class . and using the new class how to store infinite items . without touching the main class ( stack class ) .
// suppose the bug of this program is , if user types more than 10 items it will crash .
We are trying to write a bugfix class without touching the main class.
you can only access the functions push() , pop() from the main class
/// ( using inheritance) // iam trying to create a classs named Bugfix .
class Bugfix:public stack
{
protected:
////
public:
void push(int x)
int pop();
};
void Bugfix::push(int x)
{
////
}
int Bugfix::pop()
{
//
}
only change in main
main()
{
Bugfix stk; /// only change
// same as
}
how to do it. plz help me.....give some ideas ......plz help...