its a wrapper class.
it combines stl stack class with a custom user class.
i made it so that i could rename push and pop if i wanted or size and top :)
best of all it combines stack and classes :)
something i made to see if i could make it.
any better corrections or solutions would be really appreciated.
A Wrapper Class
#include <iostream>
#include <stack>
#include <string>
using namespace std;
class test{
public:
stack<string> item;
void push(string *ps){
item.push(*ps);
}
void pop(){
item.pop();
}
string top(){
item.top();
return item.top();
}
int size(){
item.size();
return item.size();
}
};
int main(){
test me;
int loop;
string input;
for(int loop=0; loop<5;loop++){
cout<<"Enter some text: ";
cin>>input;
me.push(&input);
}
while(me.size()>0){
input=me.top();
cout<<input<<endl;
me.pop();
}
}
thelamb 163 Posting Pro in Training
avarionist 1 Junior Poster in Training
thelamb 163 Posting Pro in Training
avarionist 1 Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.