Start New Discussion within our Software Development Community

I'm trying to write a stack implementation that makes use of a single link list.

The new Stack implementation can inherit from stackADT which I previously used with an array opposed to the link list I want to make use of now.

Here is the stackADT

#include "StackADT.h"

StackADT::StackADT() : current(-1) {}

void StackADT::push(void *el){
  if (!isFull()) {

void* StackADT::pop(){
  void *el = 0;
  if (!isEmpty()) {
    el = remove();
  return el;

bool StackADT::isEmpty() {
  return (current < 0) ? true : false;

bool StackADT::isFull() {
  return false; 

StackADT::~StackADT() {

int StackADT::getCurrent() {
  return current; 

void StackADT::incrCurrent() { 

void StackADT::decrCurrent() {
#ifndef STACKADT_H
#define STACKADT_H

  // Stack Abstract Data Type
  class StackADT {
      void push(void*);  // Template method
      void* pop();       // Template method 
      bool isEmpty();    // Is not implementation dependent.  Abstract class controls the variable
      virtual bool isFull();
      virtual ~StackADT();
      virtual void insert(void *) = 0; // Called by push in insert the next element in the stack
      virtual void* remove() = 0;      //  Called by pop to return the next element in the stack
      int getCurrent();    // Returns the number of elements
      void incrCurrent();  // Used by push and pop
      void decrCurrent();  // Used by push and pop
      int current;         // Number of elements in the stack


Any help would be appreciated.

This article has been dead for over six months. Start a new discussion instead.