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;
}
Programa IRPF - Guia de Instalação e Resolução de alguns Problemas
Criando uma Infraestrutura para uma micro Empresa
Criar entrada (menuentry) ISO no Grub
Como gerar qualquer emoji ou símbolo unicode a partir do seu teclado
Instalando o Pi-Hole versão v5.18.4 depois do lançamento da versão v6.0
Instalar o VIM 9.1 no Debian 12
Como saber o range de um IP público?
Muitas dificuldades ao instalar distro Linux em Notebook Sony Vaio PCG-6131L (VPCEA24FM)
Dock do debian está muito pequena (1)
Instalei Windows 11 e não alterou o Grub do Debian (0)
Linux Mint (21.2) não reconhece teclado mecanico RASEC da PCYES (2)