I am getting a error when I compile this. The error reads:
24 C:\Dev-Cpp\stacks.cpp
implicit declaration of function `int PrintStackUp(...)'
27 C:\Dev-Cpp\stacks.cpp
implicit declaration of function `int system(...)'
Code:// File: stackao.h Class, constant values, and type // definitions for C++ static implementation of ADT stack // This is the specification file for the class stack. #ifndef STACKTYPE_H #define STACKTYPE_H // application dependent size of stack const unsigned int MAX_NUM_ELS = 256; typedef int el_t; // type varies with application typedef int index_t; class stack { public: stack(); // stack constructor ~stack(); // stack deconstructor bool StackIsEmpty(void); // Is stack empty? bool StackIsFull(void); // Is stack full? void Push(el_t); // push item void Pop(el_t&); //pop top item void PrintStack(stack& s); // prints all elements of stack void Print2nd(stack& s); // prints 2nd element in stack void PrintBottom(stack& s); // prints bottom element of stack void Palindrome(stack& s ); // deterimes if characters from a palindrome private: void StackError(char*); //error handler index_t top; //top index: -1 if empty el_t el[MAX_NUM_ELS]; //container for elements }; #endif // File: stackao.cpp Contents: C++ source code for static // implementation of ADT stack. This is the implementation file. // #include<iostream.h> //#include<stdlib.h> #include "stackType.h" using namespace std; //Default constructor //Pre: None //Post: The stack object is initialized to be empty // stack::stack(void) { top = -1; } //Stack destructor //Pre: The stack has gone out of scope or an explicit call // to ~stack has occurred. //Post: The stack is empty. stack::~stack() { top = -1; } //Boolean function that returns TRUE if the stack is empty //Pre: The stack has been initialized. //Post: The function returns TRUE if the stack is empty, // FALSE otherwise. bool stack::StackIsFull(void) { return (top == -1 ? true : false); } //Boolean function that returns TRUE if a stack is full //Pre: The sack has been initialized. //Post: The function has returned TRUE if the stack is full, // FALSE otherwise. bool stack::StackIsFull(void) { return (top ++ (MAX_NUM_ELS -1) ? true : false); } //Function to push an element onto a non_full stack //Pre: e is a data element of typr el_t. // The stack is not full. //Post: If the stack was not full, e was placed on top of // the stack; otherwise StackError was called. void stack::Push(el_t e) { if ( StackIsFull()) StackError("Stack is fulle\n"); else { ++top; el[top] = e; } } // Function to pop an element from a nonempty stack and // store it in the refernced variable // Pre: The stack is nonempty. // Post: The top stack element has been removed and stored // in e. If the stack was empty, StackError was called. void stack::Pop(el_t& e) { if (StackIsEmpty()) StackError(" Stack is empty \n"); else { e = el[top]; --top; } } // Function to print an error message and abort the program //Pre: An unrecoverable error occurred. // ErrorMessage is an error message. //Post: ErrorMessage has been output and the program aborted. void stack::StackError( char* ErrorMessage) { cerr<< ErrorMessage; exit(1); } // Function to print all elements in a stack and leave stack unchanged // after printing //Pre: The stack is non empty //Post: void stack::PrintStack(stack& s) { el-t e; stack temp; While (!s.StackIsEmpty()) { s.pop(e); temp.push(e); cout<<e; } While(!temp.StackIsEmpty()) { temp.pop(e); s.push(e); } } void stack::Print2nd(stack& s) { el-t e1, e2; While(!s.StackIsEmpty()) { s.pop(e1); s.pop(e2); cout<<e2; s.push(e2); s.push(e1); } } void stack::PrintBottom(stack& s ) { el_t e; stack temp; While(!s.StackIsEmpty()) { s.pop(e); temp.push(e); } cout<<e; While(!temp.StackIsEmpty()) { temp.pop(e); s.push(e); } } void stack::Palindrome(stack& s ) { stack u,u2; el_t ch, ch1; bool equal = true; While(!s.StackIsEmpty()) { s.pop(ch); u.push(ch); u2.push(ch); } While(!u.StackIsEmpty()) { u.pop(ch); s.push(ch); } While(!u2.StackIsEmpyt() && equal) { u2.pop(ch); s.pop(ch1); if (ch != ch1) equal = false; } if (equal) cout<<"Palindrome"<<endl; else cout<<"Not a Palindrome"<<endl; } //end of Palindrome Function // This is the user program. #include <iostream> //#include <stdlib.h> #include "stackType.h" int main() { int i; char *subject = "Data Structures"; stack s; cout<< "Characters as pushed onto the stack: "; i = 0; while (( subject[i] != '\0') && (!s.StackIsFull())) { cout<< subject[i]; s.Push(subject[i]); ++i; } cout<< "\nThe stack from the bottom to top: "; PrintStackUp(s); cout<<endl; system("PAUSE"); return 0; }



LinkBack URL
About LinkBacks


