Language: C++

#include<iostream>
#include<string>
#include<stack>

int eval(std::stack<std::string> &stc){
    int a, b;
    if(stc.top == "+"){
        stc.pop;
        a = stac.top;
        stc.pop;
        b = stac.top;
        stc.pop;
        return a+b;
    } else if (stc.top == "-") {
        stc.pop;
        a = stc.top;
        stc.pop;
        b = stc.top;
        stc.pop;
        return a-b;
    } else if (stc.top == "*") {
        stc.pop;
        a = stc.top;
        stc.pop;
        b = stc.top;
        stc.pop;
        return a*b;
    }
}


int main(){
    int ans = 0;
    std::string str;
    std::stack<std::string> stc;
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);


    while(std::cin >> str != -1){
       stc.push(str);
       if(stc.top == "+" || stc.top == "-" || stc.top == "*") {
           str = to_string(eval(stc));
           stc.push(str);
       }
    }

    std::cout << stc.top << std::endl;
    return 0;
}

Compiler output:
a.cc: In function 'int eval(std::stack<std::__cxx11::basic_string<char> >&)':
a.cc:7:16: error: invalid operands of types '<unresolved overloaded function type>' and 'const char [2]' to binary 'operator=='
    7 |     if(stc.top == "+"){
      |        ~~~~~~~ ^~ ~~~
      |            |      |
      |            |      const char [2]
      |            <unresolved overloaded function type>
a.cc:8:13: error: invalid use of non-static member function 'void std::stack<_Tp, _Sequence>::pop() [with _Tp = std::__cxx11::basic_string<char>; _Sequence = std::deque<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char> > >]'
    8 |         stc.pop;
      |         ~~~~^~~
In file included from /usr/include/c++/14/stack:63,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_stack.h:291:7: note: declared here
  291 |       pop()
      |       ^~~
a.cc:9:13: error: 'stac' was not declared in this scope; did you mean 'stc'?
    9 |         a = stac.top;
      |             ^~~~
      |             stc
a.cc:10:13: error: invalid use of non-static member function 'void std::stack<_Tp, _Sequence>::pop() [with _Tp = std::__cxx11::basic_string<char>; _Sequence = std::deque<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char> > >]'
   10 |         stc.pop;
      |         ~~~~^~~
/usr/include/c++/14/bits/stl_stack.h:291:7: note: declared here
  291 |       pop()
      |       ^~~
a.cc:12:13: error: invalid use of non-static member function 'void std::stack<_Tp, _Sequence>::pop() [with _Tp = std::__cxx11::basic_string<char>; _Sequence = std::deque<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char> > >]'
   12 |         stc.pop;
      |         ~~~~^~~
/usr/include/c++/14/bits/stl_stack.h:291:7: note: declared here
  291 |       pop()
      |       ^~~
a.cc:14:24: error: invalid operands of types '<unresolved overloaded function type>' and 'const char [2]' to binary 'operator=='
   14 |     } else if (stc.top == "-") {
      |                ~~~~~~~ ^~ ~~~
      |                    |      |
      |                    |      const char [2]
      |                    <unresolved overloaded function type>
a.cc:15:13: error: invalid use of non-static member function 'void std::stack<_Tp, _Sequence>::pop() [with _Tp = std::__cxx11::basic_string<char>; _Sequence = std::deque<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char> > >]'
   15 |         stc.pop;
      |         ~~~~^~~
/usr/include/c++/14/bits/stl_stack.h:291:7: note: declared here
  291 |       pop()
      |       ^~~
a.cc:16:17: error: cannot resolve overloaded function 'top' based on conversion to type 'int'
   16 |         a = stc.top;
      |                 ^~~
a.cc:17:13: error: invalid use of non-static member function 'void std::stack<_Tp, _Sequence>::pop() [with _Tp = std::__cxx11::basic_string<char>; _Sequence = std::deque<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char> > >]'
   17 |         stc.pop;
      |         ~~~~^~~
/usr/include/c++/14/bits/stl_stack.h:291:7: note: declared here
  291 |       pop()
      |       ^~~
a.cc:18:17: error: cannot resolve overloaded function 'top' based on conversion to type 'int'
   18 |         b = stc.top;
      |                 ^~~
a.cc:19:13: error: invalid use of non-static member function 'void std::stack<_Tp, _Sequence>::pop() [with _Tp = std::__cxx11::basic_string<char>; _Sequence = std::deque<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char> > >]'
   19 |         stc.pop;
      |         ~~~~^~~
/usr/include/c++/14/bits/stl_stack.h:291:7: note: declared here
  291 |       pop()
      |       ^~~
a.cc:21:24: error: invalid operands of types '<unresolved overloaded function type>' and 'const char [2]' to binary 'operator=='
   21 |     } else if (stc.top == "*") {
      |                ~~~~~~~ ^~ ~~~
      |                    |      |
      |                    |      const char [2]
      |                    <unresolved overloaded function type>
a.cc:22:13: error: invalid use of non-static member function 'void std::stack<_Tp, _Sequence>::pop() [with _Tp = std::__cxx11::basic_string<char>; _Sequence = std::deque<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char> > >]'
   22 |         stc.pop;
      |         ~~~~^~~
/usr/include/c++/14/bits/stl_stack.h:291:7: note: declared here
  291 |       pop()
      |       ^~~
a.cc:23:17: error: cannot resolve overloaded function 'top' based on conversion to type 'int'
   23 |         a = stc.top;
      |                 ^~~
a.cc:24:13: error: invalid use of non-static member function 'void std::stack<_Tp, _Sequence>::pop() [with _Tp = std::__cxx11::basic_string<char>; _Sequence = std::deque<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char> > >]'
   24 |         stc.pop;
      |         ~~~~^~~
/usr/include/c++/14/bits/stl_stack.h:291:7: note: declared here
  291 |       pop()
      |       ^~~
a.cc:25:17: error: cannot resolve overloaded function 'top' based on conversion to type 'int'
   25 |         b = stc.top;
      |                 ^~~
a.cc:26:13: error: invalid use of non-static member function 'void std::stack<_Tp, _Sequence>::pop() [with _Tp = std::__cxx11::basic_string<char>; _Sequence = std::deque<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char> > >]'
   26 |         stc.pop;
      |         ~~~~^~~
/usr/include/c++/14/bits/stl_stack.h:291:7: note: declared here
  291 |       pop()
      |       ^~~
a.cc: In function 'int main()':
a.cc:40:27: error: no match for 'operator!=' (operand types are 'std::basic_istream<char>' and 'int')
   40 |     while(std::cin >> str != -1){
      |           ~~~~~~~~~~~~~~~ ^~ ~~
      |                    |         |
      |                    |         int
      |                    std::basic_istream<char>
a.cc:40:27: note: candidate: 'operator!=(int, int)' (built-in)
   40 |     while(std::cin >> str != -1){
      |           ~~~~~~~~~~~~~~~~^~~~~
a.cc:40:27: note:   no known conversion for argument 1 from 'std::basic_istream<char>' to 'int'
In file included from /usr/include/c++/14/iosfwd:42,
                 from /usr/include/c++/14/ios:40,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/postypes.h:197:5: note: candidate: 'template<class _StateT> bool std::operator!=(const fpos<_StateT>&, const fpos<_StateT>&)'
  197 |     operator!=(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/14/bits/postypes.h:197:5: note:   template argument deduction/substitution failed:
a.cc:40:31: note:   'std::basic_istream<char>' is not derived from 'const std::fpos<_StateT>'
   40 |     while(std::cin >> str != -1){
      |                               ^
In file included from /usr/include/c++/14/string:43,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44:
/usr/include/c++/14/bits/allocator.h:243:5: note: candidate: 'template<class _T1, class _T2> bool std::operator!=(const allocator<_CharT>&, const allocator<_T2>&)'
  243 |     operator!=(const allocator<_T1>&, const allocator<_T2>&)
      |     ^~~~~~~~
/usr/include/c++/14/bits/allocator.h:243:5: note:   template argument deduction/substitution failed:
a.cc:40:31: note:   'std::basic_istream<char>' is not derived from 'const std::allocator<_CharT>'
   40 |     while(std::cin >> str != -1){
      |                               ^
In file included from /usr/include/c++/14/string:48:
/usr/include/c++/14/bits/stl_iterator.h:455:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
  455 |     operator!=(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:455:5: note:   template argument deduction/substitution failed:
a.cc:40:31: note:   'std::basic_istream<char>' is not derived from 'const std::reverse_iterator<_Iterator>'
   40 |     while(std::cin >> str != -1){
      |                               ^
/usr/include/c++/14/bits/stl_iterator.h:500:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  500 |     operator!=(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:500:5: note:   template argument deduction/substitution failed:
a.cc:40:31: note:   'std::basic_istream<char>' is not derived from 'const std::reverse_iterator<_Iterator>'
   40 |     while(std::cin >> str != -1){
      |                               ^
/usr/include/c++/14/bits/stl_iterator.h:1686:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1686 |     operator!=(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1686:5: note:   template argument deduction/substitution failed:
a.cc:40:31: note:   'std::basic_istream<char>' is not derived from 'const std::move_iterator<_IteratorL>'
   40 |     while(std::cin >> str != -1){
      |                               ^
/usr/include/c++/14/bits/stl_iterator.h:1753:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
 1753 |     operator!=(const move_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1753:5: note:   template argument deduction/substitution failed:
a.cc:40:31: note:   'std::basic_istream<char>' is not derived from 'const std::move_iterator<_IteratorL>'
   40 |     while(std::cin >> str != -1){
      |                               ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/str