#include <iostream>
#include <cstring>
using namespace std;
class Stack
{
private:
char *Cad[20];
int len[20];
int indice;
char buffer[50];
public:
Stack() : indice(0) {}
void push(char *cad)
{
if(indice < 20)
{
len[indice] = static_cast<int>(strlen(cad));
Cad[indice] = new char[len[indice]];
memcpy(Cad[indice], cad, len[indice]);
indice++;
}
}
const char* pop()
{
memset(buffer,'\0',50);
if(indice >= 0)
{
indice--;
memcpy(buffer, Cad[indice], len[indice]);
delete[] Cad[indice];
}
return buffer;
}
};
int main()
{
Stack obj;
obj.push("hola");
obj.push("ver");
cout << obj.pop() << endl;
cout << obj.pop() << endl;
obj.push("como");
cout << obj.pop() << endl;
return 0;
}