Enviado em 10/11/2018 - 22:50h
Boa noite pessoal.#ifndef CELL_H
#define CELL_H
class Cell
{
public:
Cell(int value, Cell *next);
~Cell();
int value() const { return m_value; }
Cell *next() const {return m_next; }
private:
int m_value;
Cell *m_next;
};
#endif
#include "cell.h"
#include <iostream>
using namespace std;
Cell::Cell(int value, Cell *next): m_value(value), m_next(next)
{
//Empty
}
#include "cell.h"
#include <iostream>
using namespace std;
Cell::Cell(int value, Cell *next): m_value(value), m_next(next)
{
//Empty
}
#include "stack.h"
#include "cell.h"
#include <assert.h>
#include <iostream>
using namespace std;
Stack::Stack():m_firstCellPtr(nullPtr), m_size(0)
{
//Empty
}
void Stack::push(int value)
{
m_firstCellPtr = new Cell(value, m_firstCellPtr);
++m_size;
}
int Stack::top()
{
assert(!empty());
return m_firstCellPtr->getValue();
}
void Stack::pop()
{
assert(!empty());
Cell *deleteCellPtr = m_firstCellPtr;
m_firstCellPtr = m_firstCellPtr->getNext();
delete deleteCellPtr;
--m_size;
}
int Stack::size() const
{
return m_size;
}
bool Stack::empty() const
{
return (m_firstCellPtr == nullPtr);
}
#include <string.h>
#include <iostream>
#include "cell.h"
#include "stack.h"
using namespace std;
int main(int argc, char const *argv[])
{
Stack s;
s.push(1);
s.push(2);
s.push(3);
cout <<"\nTop: " << s.top() <<", size: " << s.size() <<", empty " << (s.empty() ? "true" : "false") << endl;
s.pop();
s.pop();
s.push(4);
cout <<"\nTop: " << s.top() <<", size: " << s.size() <<", empty " << (s.empty() ? "true" : "false") << endl;
return 0;
}
Passkeys: A Evolução da Autenticação Digital
Instalação de distro Linux em computadores, netbooks, etc, em rede com o Clonezilla
Título: Descobrindo o IP externo da VPN no Linux
Armazenando a senha de sua carteira Bitcoin de forma segura no Linux
Enviar mensagem ao usuário trabalhando com as opções do php.ini
Instalando Brave Browser no Linux Mint 22
vídeo pra quem quer saber como funciona Proteção de Memória:
Encontre seus arquivos facilmente com o Drill
Mouse Logitech MX Ergo Advanced Wireless Trackball no Linux
Compartilhamento de Rede com samba em modo Público/Anônimo de forma simples, rápido e fácil
Programa duplicado no "Abrir com" e na barra de pesquisa do ... (1)
VMs e Interfaces de Rede desapareceram (13)
Como abrir o pycharm no linux [RESOLVIDO] (4)