Here is my code for the Stack.h:
#ifndef STACK_H
#define STACK_H
#include <iostream>
#include <iomanip>
using namespace std;
class Stack
{
//friend function
friend ostream& operator<< (ostream& leftOp, const Stack& rightOp)
private:
//data members
int *arraystack;
int arraysize;
int artop;
public:
//methods prototype
Stack(int size);
Stack(const char* s);
~Stack();
Stack& operator = (const Stack& rightOp) const;
void clean();
int size();
bool empty();
int top();
void push(int);
void pop();
};
#endif
Just want to know if my data members are ok. Here is the instruction for data members:
Data members
This class contains a dynamically allocated array of integer data values (the stack array). Because the array is allocated dynamically, an integer value is also maintained inside the class to determine the maximum number of elements that may be stored in the array (the stack capacity).
The class also requires two other integer data members: the number of data items currently stored in the stack (the stack size), and the subscript of the top item in the stack (the stack top subscript). Don't give these data members the same names as methods of the class.
Thank you!
#ifndef STACK_H
#define STACK_H
#include <iostream>
#include <iomanip>
using namespace std;
class Stack
{
//friend function
friend ostream& operator<< (ostream& leftOp, const Stack& rightOp)
private:
//data members
int *arraystack;
int arraysize;
int artop;
public:
//methods prototype
Stack(int size);
Stack(const char* s);
~Stack();
Stack& operator = (const Stack& rightOp) const;
void clean();
int size();
bool empty();
int top();
void push(int);
void pop();
};
#endif
Just want to know if my data members are ok. Here is the instruction for data members:
Data members
This class contains a dynamically allocated array of integer data values (the stack array). Because the array is allocated dynamically, an integer value is also maintained inside the class to determine the maximum number of elements that may be stored in the array (the stack capacity).
The class also requires two other integer data members: the number of data items currently stored in the stack (the stack size), and the subscript of the top item in the stack (the stack top subscript). Don't give these data members the same names as methods of the class.
Thank you!
Comment