-1

I'm trying to solve a balanced parentheses problem, here in my code I'm trying to get 1 from a function is_empty() if top of my stack is empty but then here i am stuck with this ugly error.

int is_Empty()
{
    int x=0;
    if (top==NULL)
    {
    x=1;
    }
    return x;
}

here is how i recive it

if (s1.is_Empty==1)
    {
        cout<<"matched"<<endl;
    }

my error log

bal.cpp:112:20: error: invalid use of member 'int stack::is_Empty()' (did you forget the '&' ?)        
             if (s1.is_Empty==1)
                 ~~~^~~~~~~~
melpomene
  • 84,125
  • 8
  • 85
  • 148
Pawan Nirpal
  • 565
  • 1
  • 12
  • 29

1 Answers1

3
if (s1.is_Empty==1)

That is not how to call a function.

Here:

if (s1.is_Empty()==1)

You may wish to review your C++ book.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
  • oh i get it, the parentheses for function how silly of me , i feel like an idiot. – Pawan Nirpal Aug 28 '19 at 17:48
  • Error description could also do a better job here though. I bet more people miss the `()` as a typo vs those who wanted to take the address or something that the diagnostics is saying is probably missing. I don't have a machine at hand just now but I think several languages would produce better/direct hints to just guide novices more ? It does mention invalid use of `is_Empty()` so that's a hint but it could ask if the user missed `()` later too. – ustulation Aug 28 '19 at 17:56
  • @ustulation I agree. – Lightness Races in Orbit Aug 28 '19 at 17:58
  • anyways thanks for pointing out a silly error i'll mind being more conscious about syntax then just getting carried away by the logic part ;) – Pawan Nirpal Aug 28 '19 at 17:58