daria-grebneva / OOP

0 stars 0 forks source link

Замечания по StringStack #21

Open alexey-malov opened 6 years ago

alexey-malov commented 6 years ago
void CStringStack::CopyStackItems(CStringStack const& stack)
{
    if (!stack.IsEmpty())
    {
        std::shared_ptr<StackItem> copiedItem = stack.m_top;

        m_top = std::make_shared<StackItem>(*copiedItem);
        auto pasteItem = m_top;

        pasteItem->stringContent = copiedItem->stringContent;

        while (copiedItem->next != nullptr)
        {
            pasteItem->next = std::make_shared<StackItem>(*copiedItem->next); // (1)

            copiedItem = copiedItem->next;
            pasteItem = pasteItem->next;
        }

        m_stackSize = stack.m_stackSize;
    }
}
bool CStringStack::IsEmpty() const
{
    return (m_stackSize == 0);
}

void CStringStack::Clear()
{
    while (!IsEmpty())
    {
        Pop();
    }
}
AniSkyWorker commented 6 years ago
oMystique commented 6 years ago