Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8628107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:27:09+00:00 2026-06-12T08:27:09+00:00

Here is what I have for an error: In file included from braincalc.cpp:8:0: AbstractStack.h:43:1:

  • 0

Here is what I have for an error:

In file included from braincalc.cpp:8:0:
AbstractStack.h:43:1: error: expected class-name before â{â token

Here is my .h:

//AbstractStack.h

#ifndef ABSTRACTSTACK_H
#define ABSTRACTSTACK_H

#include<iostream>
using namespace std;

template < typename T >
class AbstractStack
{
public:

  // Purpose: clears the stack
  // Postconditions: the stack is now empty 
  virtual void clear() = 0;

  // Purpose: push an element into the stack
  // Parameters: x is the value to push into the stack
  // Postconditions: x is now the element at the top of the stack, 
  virtual void push(T x) = 0;


  // Purpose: pop the stack
  // Postconditions: the element formerly at the top of the stack has
  // been removed
  // Panic: if the stack is currently empty, PANIC!
  virtual void pop() = 0;


  // Purpose: looks at the top of the stack
  // Returns: a reference to the element currently on top of the stack
  // Panic: if the stack is currently empty, PANIC!

  virtual T& top() = 0;


  // Purpose: Checks if a stack is empty
  // Returns: 'true' if the stack is empty
  //     'false' otherwise  
  virtual bool isEmpty() = 0;
};

class LinkedStack: public AbstractStack
{
  public:
    int m_data;
    LinkedStack *m_next;

    void clear()
    {
      LinkedStack *p;
      LinkedStack *tmp;

      while(m_next != NULL)
      {
        p = this;
        tmp = p -> m_next;
        delete p;
      }
    } 

    void push(int x)
    {
      LinkedStack *tmp = new LinkedStack;
      tmp -> m_data = m_data;
      tmp -> m_next = m_next;
      m_data = x;
      m_next = tmp;
    }

    void pop()
    {
      LinkedStack *tmp;

      if (m_next != NULL)
      {
        tmp = m_next;
        m_data = tmp -> m_data;
        m_next = tmp -> m_next;
        delete tmp;
      }
    }

    int& top()
    {
        return m_data;
    }

    bool isEmpty()
    {
      bool empty = false;

      if (m_next == NULL)
      {
        empty = true;
      }

      return empty;
    }
};

#endif

Here is the .cpp:

//braincalc.cpp

#include"AbstractStack.h"
#include<string>
#include<cstdlib>


int main()
{
  string input;
  bool again=true;
  int ctr=0;
  int temp1, temp2;
  LinkedStack stack;

  do
  {
    getline(cin, input, '$');
    input.c_str();

    if (isdigit(input[ctr]))
    {
      stack.push(atoi(&input[ctr]));
      ctr++;
    }

    else if (isspace(input[ctr]))
    {
      ctr++;
    }

    else if (input[ctr] == '*')
    {
      temp2 = stack.top();
      stack.pop();
      temp1 = stack.top();
      stack.pop();
      stack.push(temp1 * temp2);
      ctr++;
    }

    else if (input[ctr] == '/')
    {
      temp2 = stack.top();
      stack.pop();
      temp1 = stack.top();
      stack.pop();
      stack.push(temp1 / temp2);
      ctr++;
    }

    else if (input[ctr] == '+')
    {
      temp2 = stack.top();
      stack.pop();
      temp1 = stack.top();
      stack.pop();
      stack.push(temp1 + temp2);
      ctr++;
    }

    else if (input[ctr] == '-')
    {
      temp2 = stack.top();
      stack.pop();
      temp1 = stack.top();
      stack.pop();
      stack.push(temp1 - temp2);
      ctr++;
    }

    else if (input[ctr] == '!')
    {
      temp1 = stack.top();
      stack.pop();
      stack.push(-temp1);
      ctr++;
    }

    else if (input[ctr] == '#')
    {
      again = false;
      ctr=0;
    }

  } while(again == true);

  cout << "["<<stack.top()<<"]"<<endl;

  return 0;
}

The code is not done I realize, but this error makes it so that I cannot test to see if it works like I think it will or not. Thanks ahead of time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T08:27:11+00:00Added an answer on June 12, 2026 at 8:27 am

    AbstractStack is not a class, so you can’t write:

    class LinkedStack: public AbstractStack
    

    You’ll either have to make LinkedStack a template:

    template<class T>
    class LinkedStack: public AbstractStack<T>
    

    or derive from a specialization of AbstractStack:

    class LinkedStack: public AbstractStack<int>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's the error: In file included from /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/ios:39, from /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/ostream:40, from /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/iostream:40, from date.h:15,
I have JPA entities as outlined here: QueryDSL JPA syntax error with contains on
I have a pretty nasty error I can't get rid of. Here's the function
I have a gwt project that uses gwt-mosaic. Here is the error message I
Getting this weird LINQ error. title = System.Linq.Enumerable+WhereSelectEnumerableIterator`2[System.Xml.Linq.XElement,System.String Here is the code I have:
I have two arrays: $array1 = array(1=>1,10=>1,12=>0,13=>13); $array2 = array(1=>Hello,10=>Test,12=>check,13=>error); Here $array1 has keys
Here I have declared another virtual function in Derived class. #include <iostream> using namespace
I have some code in c++ in which my main.cpp includes a file SimpleGraph.h.
I have an xml file which I included as a resource in my netbeans
I have a class that inherits from a base class and implements the following...

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.