Click to See Complete Forum and Search --> : Write a function to figure out if stack grows up or down


dullboy
November 3rd, 2005, 04:31 PM
Would anybody please gives a hint how to do it? Thanks for your inputs.

RoboTact
November 4th, 2005, 09:45 AM
If you feed it according to diet, it would certaintly grow without wrong amount of fat. Please be more specific...

dullboy
November 4th, 2005, 10:48 AM
For example, I have a stack class defined as the following,

class stack
{
public:
int pop();
void push(int data);
bool isEmpty();
private:
int top;

};

Can you give me an idea how to implement a member function UpORDown() defined as bool UpOrDown() to figure out if the stack grows up or down?
If you feed it according to diet, it would certaintly grow without wrong amount of fat. Please be more specific...

Pinky98
November 4th, 2005, 10:53 AM
That makes ABSOLUTELY no sense?!? Firstly how do you define up and down. and secondly how you program it will depend on whether it grows UP or DOWN.

RoboTact
November 4th, 2005, 11:23 AM
:confused:

class stack
{
public:
int pop(){up=true; /* ... */}
void push(int data){up=false; /* ... */}
bool isEmpty();
bool isUp(){return up;}
private:
bool up;
int top;

};

Can you give me an idea how to implement a member function UpORDown() defined as bool UpOrDown() to figure out if the stack grows up or down?"Up or down?"
"Yes."