title: What happens if a thrown value matches several catch clauses?
body: <p>Literally what happens if one value thrown does match several catch clauses?</p>
  
  <p>The compiler decides it or it makes errors?</p>
  
  <p>The following is an example with one value thrown and that matches three catch clauses.</p>
  
  <p>I compile it and get errors. But don't know what that error means...</p>
  
  <pre><code>    #include &lt;iostream&gt;
      using namespace std;
  
      class AAA
      {
      public:
          void ShowYou() { cout&lt;&lt;"AAA exception!"&lt;&lt;endl; }
      };
  
      class BBB : public AAA
      {
      public:
          void ShowYou() { cout&lt;&lt;"BBB exception!"&lt;&lt;endl; }
      };
  
      class CCC : public BBB
      {
      public:
          void ShowYou() { cout&lt;&lt;"CCC exception!"&lt;&lt;endl; }
      };
  
      void ExceptionGenerator(int expn)
      {
          if(expn==1)
              throw AAA();
          else if(expn==2)
              throw BBB();
          else
              throw CCC();
      }
  
      int main(void)
      {
          try
          {
              ExceptionGenerator(1);
              ExceptionGenerator(1);
              ExceptionGenerator(1);
          }
  
          catch(AAA&amp; expn)
          {
              cout&lt;&lt;"catch(AAA&amp; expn)"&lt;&lt;endl;
              expn.ShowYou();
          }   
  
          catch(AAA&amp; expn)
          {
              cout&lt;&lt;"catch(BBB&amp; expn)"&lt;&lt;endl;
              expn.ShowYou();
          }
  
          catch(AAA&amp; expn)
          {
                cout&lt;&lt;"catch(CCC&amp; expn)"&lt;&lt;endl;
                expn.ShowYou();
          }
        system("pause"); return 0;
  }
  </code></pre>
  
  <p>Error   1   error C2312: 'AAA &amp;' : is caught by 'AAA &amp;' on line 40</p>
  
  <p>I get the error above.</p>
  
  <p>What does it mean by that?</p>