hi all...
i have a weird compilation error... when i declared an object
|error: no matching function for call to `Stack::Stack()'| !!!!!!
this is the code!!
and also i have a question...Code:#include <iostream> #include <fstream> using namespace std; class Stack { private: char *stackArr; int Size; int top; public: Stack (int s) { stackArr= new char[s]; Size= s; top= -1; } ~Stack () { delete[] stackArr; } bool Push (char c) { if(top == Size-1) // stack is full return false; else { top++; stackArr[top]= c; return true; } } bool Pop (char & c) { if(isEmpty()) return false; else { c= stackArr[top]; top--; return true; } } bool Peek (char & c) { if(top==-1) return false; c= stackArr[top]; return true; } bool isEmpty () { return top== false; } }; int main() { Stack S,St; ifstream inFile; ofstream outFile; char c; int counter=0; inFile.open("File1.txt"); if(!inFile) { cout<<"UNABLE TO OPEN THIS FILE!!! "<<endl; exit(1); // terminated with error } else Stack(100); while(inFile!=NULL) { inFile.get(c); S.Push (c); counter++; } outFile.open("File2.txt"); while(!outFile) { if(!S.isEmpty()) { S.Pop(c); outFile<< S.Peek(c); cout<<endl; } } return 0; }
i want to read from a text file then copy every character into a stack after that i have to save it in another text file in reverse order
who could teach me how can i save it in reverse order please ?!!
i'm new in stack and really i have problem with using it![]()



LinkBack URL
About LinkBacks




