Hi, all i have big assignment and don't have any compiler problem just have runtime bug--this make more headache.
Here is the driver;
int main{
int * values2 = new int [ARRAY_SIZE * 2];
values2[ARRAY_SIZE * 2 - 2] = 8;
values2[ARRAY_SIZE * 2 - 1] = 5;
stack.pop (values2, 0);
/*stack belong to Intstack class and the pop function is to pop everything inside the stack into the values2;that means pop(values2,0) didn't do anything, but pop(values2,1) means pop out the top int element inside stack to the values2[0]. There already have 200 int element inside the intstack*/
stack.pop (values2, 1);
stack.pop (&(values2[1]),ARRAY_SIZE - 1);
//print out the array
std::cout << "About to output values2 arrays" << std::endl;
for (i = 0; i < COUNTOF (values); ++i)
{
std::cout << << values2 [i] << std::endl;
}
std::cout << "Finished output of values2 arrays" << std::endl;
}
Here is my code
class Intstack
{
//private element top, p and size;
//public functions and constructor including pop and overload pop function;
};
void IntStack::pop(int a[],size_t n)//this is my pop function to implement the main
{
for(int i=0;i<n;i++)
{
if(top==-1)
{cout<<"There is empty\n";}
else
{
int v;
v=p[top];
top--;
a[i]=v;
}
}
}
So basically, the results should like:
About to output values2 arrays
element from 1-200
Finished output of values2 arrays