Nechce se na to nekdo skilled podivat?:)
Kód: Vybrat vše
class SStk {
public:
/* ... */
void push(const std::string & s);
private:
std::string * p_;
int allocated_, used_;
};
void SStk::push (const std::string & s) {
if (used_ >= allocated) {
int n2 = (allocated_ +1) * 2;
std::string * p2 = new string[n2];
for(int i = 0; i < used_; ++i)
p2[i] = p_[i];
delete[] p_;
p_ = p2;
allocated_ = n2;
}
p_[used_] = s;
++used_;
}