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 7511509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:34:03+00:00 2026-05-29T23:34:03+00:00

i am working on this program ,but i am receiving 2 errors , i

  • 0

i am working on this program ,but i am receiving 2 errors , i cant know what they mean or how i fix them ….
the program should read any equation as a+b-c or (a+b)-c …etc
and check if the parenthesis match or not
here is the code

// A simple Integer stack, Array based
#include <string>
#include <iostream>
#define STACK_MAX 100
#define equation

using namespace std;
template <typename type>
class Stack {

private:
    type        data[STACK_MAX];
    int        size;

public:
    Stack();
    ~Stack() { }   // Destructor
    int top();
    void push(int d) ;
    void pop() ;
    int is_full ();
    int is_empty () ;
    void equal( Stack& entry) ;
};
template <typename type > int Stack<type>::is_full () {
    return ( STACK_MAX >= size );
}
template <typename type > int Stack<type>::is_empty () {
    return ( STACK_MAX == 0 );
}
template <typename type>  Stack <type>::Stack() {
    size = 0;
}
template <typename type > int Stack< type >:: top() {

    if (is_empty ()) {
        printf("Error: stack empty\n");
        return -1;
    }
    return data[size-1];
}
template <typename type > void Stack <type>::push (int d) {

    if (! is_full () ) {
        data[size++] = d;
    } else {
        printf("Error: stack full\n");
    }
}
template < typename type > void Stack <type>::pop() {

    if (size == 0) {
        printf("Error: stack empty\n");
    } else {
        size--;
    }
}
template <typename type > void Stack <type> ::equal ( Stack& entry ) {
    std::string& equation ;
    char left = '(' ;
    char right= ')' ;
    Stack <type> x ;
    string::size_type a ;
    char next ;
    next = entry ;
    bool failed = false ;
    for ( a= 0 ; ! equation.length() ; ++a) {
        next = equation[a] ;
        if ( next == left ) {
            x.push (next);
        } else {
            if (x.is_empty()) {
                x.pop () ;
            } else {
                failed = true ;
            }
        }

    }
    if ( a == 0) {
        cout << " No parenthesis"<< endl ;
    } else if ( x.top () == left ) {
        cout << "Parenthesis don’t match. Missing right parenthesis" << endl ;
    } else if ( x.top () == right ) {
        cout << "Parenthesis don’t match. Missing left parenthesis " << endl ;
    } else {
        cout << "Matching parenthesis" << endl ;
    }

}


int main() {

    Stack <char> equation2 ;
    char b ;
    cout << " please enter your equation " << endl ;
    for (int i =0 ; i< 100 ; i++ ) {

        cin >> b ;
        equation2.equal(b) ;
    }


    system ("pause") ;


    return 0;
}

and here are the errors

    2   IntelliSense: a reference of type "Stack<char> &" (not const-qualified) cannot be initialized with a value of type "char"   c:\users\mike\documents\visual studio 2010\projects\stack\stack\stack.cpp   101
   Error    1   error C2664: 'Stack<type>::equal' : cannot convert parameter 1 from 'char' to 'Stack<type> &'   c:\users\mike\documents\visual studio 2010\projects\stack\stack\stack.cpp   101
  • 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-05-29T23:34:06+00:00Added an answer on May 29, 2026 at 11:34 pm

    The previous answer was for some reason deleted so I guess I’ll post one instead.

    As you said, equal’s current implementation depends on the type to work on is a char, which would render changing the signature to type& quite meaningless because it would still only work as expected if you instantiated the templated class using the type char. Still, the current problem is that the equal signature takes a Stack& which is wrong, you should change to char

    template <typename type > void Stack <type> ::equal ( Stack& entry ) 
    

    to

    template <typename type > void Stack <type> ::equal ( char& entry ) 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a bug in this program where it should be able
I have been working on this program but everytime I attempt to build, I
This program takes 2 numbers from user input, asks them whether they'd like to
Total newb to .NET programming (and AJAX) but I've been working on this program
I need to understand the working of this particular program, It seems to be
My friend and I are working on a program. This program is going to
This is the last part of the program I am working on. I want
I have this working great, but I'd like a deeper understanding of what is
Okay so im working on this php image upload system but for some reason
I've been working on this elevator program for quite some time now and finally

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.