title: Error: expected primary expression before '.' token
body: <p>I'm trying to write a code to check the bracket pairs in an input string and print out either "Success" (for an input with matched pair) or the the 1-based index of the first unmatched closing bracket. </p>
  
  <p>However I'm getting an error:</p>
  
  <blockquote>
    <p>expected primary expression before '.' token </p>
  </blockquote>
  
  <p>when I compile. </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;stack&gt;
  #include &lt;string&gt;
  
  struct Bracket {
      Bracket(char type, int position):
          type(type),
          position(position)
      {}
  
      bool Matchc(char c) {
          if (type == '[' &amp;&amp; c == ']')
              return true;
          if (type == '{' &amp;&amp; c == '}')
              return true;
          if (type == '(' &amp;&amp; c == ')')
              return true;
          return false;
  
      }
  
      char type;
      int position;
  };
  
  
  int main() {
      std::string text;
      getline(std::cin, text);
      int z;
  
      std::stack &lt;Bracket&gt; opening_brackets_stack;
      for (int position = 0; position &lt; text.length(); ++position) {
          char next = text[position];
  
          if (next == '(' || next == '[' || next == '{') {
              opening_brackets_stack.push(Bracket(next,0));
          }
  
          if (next == ')' || next == ']' || next == '}') {
  
              if(Bracket.Matchc(next) == false || opening_brackets_stack.empty() == false)
              {
                 z = position;
              }
  
              else
              {
                  opening_brackets_stack.pop();
              }
  
          }
      }
  
      if (opening_brackets_stack.empty())
      {
          std::cout &lt;&lt; "Success";
      }
  
      else
      {
          std::cout &lt;&lt; z;
      }
      return 0;
  }
  </code></pre>