title: Why am i getting segmentation fault using pointer?
body: <p>I am getting segmentation fault when i pass 8 computer class pointers to the Tournament class and trying to manipulate those pointers. The tournament class takes 8 Computer derived players and will call the Refree Function to Decide the number of wins of each player.
  For example: Input: Tournament league(computer *Player1, *player2 ... etc)
               output: segmentation fault or doesnt print anything at all.</p>
  
  <pre><code> class Computer{
          public:
              Computer();
              Computer(int number);
              int get_c_number();
              friend class Refree;
              friend class Tournament;
          public:
              string c_game;
              int c_number;
              static int no_of_win;
              string c_name;
      };
      #include "computer.h"
      Computer::Computer(){
  
      }
      //====computer.cpp
      int Computer::no_of_win=0;
      Computer::Computer(int number){
          c_number = number;
  
          for(int i=0; i&lt;c_number; i++)
          {
              c_game.push_back('R');
          }
  
      }
      int Computer::get_c_number()
      {
          return c_number;
      }
      //=====example computer child class==
      #ifndef _TOOLBOX_H
      #define _TOOLBOX_H
      #include "computer.h"
      #include &lt;string&gt;
      #include &lt;iostream&gt;
  
      class Toolbox:public Computer{
          public:
              Toolbox();
              Toolbox(int number);
          private:
  
  
      };
      #endif //
      #include "toolbox.h"
      Toolbox::Toolbox(){};
      Toolbox::Toolbox(int number){
          c_number = number;
  
          for(int i=0; i&lt;c_number; i++)
          {
              c_game.push_back('S');
          }
  
  
      };
      //=========tournament class==
      #define _TOURNAMENT_H
      #include "computer.h"
      #include "refree.h"
      #include &lt;string&gt;
      #include &lt;iostream&gt;
      #include &lt;time.h&gt;
      #include &lt;ctime&gt;
      #include &lt;stdlib.h&gt;
      class Tournament:public Computer{
          public:
              Tournament();
              Tournament(Computer *A, Computer *B, Computer *C, Computer *D, Computer *E, Computer *F, Computer *G, Computer *H);
              void decision();
  
          private:
              static int number_of_games;
               Computer *tournament[8];
               Computer *tournament2[4];
               Computer *tournament3[2];
  
  
      };
      #endif //_TOURNAMENT_H
      //======tournament.cpp===
      #include "tournament.h"
      int Tournament::number_of_games = 5;
      Tournament::Tournament(Computer *A, Computer *B, Computer *C, Computer *D, Computer *E, Computer *F, Computer *G, Computer *H){
          tournament[0] = A;
          tournament[1] = B;
          tournament[2] = C;
          tournament[3] = D;
          tournament[4] = E;
          tournament[5] = F;
          tournament[6] = G;
          tournament[7] = H;
      };
  
      void Tournament::decision(){
          Refree number1(tournament[0], tournament[1]), number2(tournament[2], tournament[3]), number3(tournament[4], tournament[5]), number4(tournament[6], tournament[7]);
          number1.decision2();
          number2.decision2();
          number3.decision2();
          number4.decision2();
         for(int i=0; i&lt;4; i++)
          {
              if(tournament[(2*i)]-&gt;no_of_win &gt; tournament[(2*i)+1]-&gt;no_of_win)
              {
                  tournament[(2*i)]-&gt;no_of_win = 0;
                  tournament[(2*i)+1]-&gt;no_of_win = 0;
                  tournament2[i] = tournament[(2*i)];
              }
              else if(tournament[(2*i)]-&gt;no_of_win &lt; tournament[(2*i)+1]-&gt;no_of_win)
              {
                  tournament[(2*i)]-&gt;no_of_win = 0;
                  tournament[(2*i)+1]-&gt;no_of_win = 0;
                  tournament2[i] = tournament[(2*i)+1];
              }
          }
  
  
              Refree number5(tournament2[0], tournament2[1]), number6(tournament2[2], tournament2[3]);
              number5.decision2();
              number6.decision2();
  
          for(int i=0; i&lt;2; i++)
          {
              if(tournament2[(2*i)]-&gt;no_of_win &gt; tournament2[(2*i)+1]-&gt;no_of_win)
              {
                  tournament2[(2*i)]-&gt;no_of_win = 0;
                  tournament2[(2*i)+1]-&gt;no_of_win = 0;
                  tournament3[i] = tournament2[(2*i)];
              }
              else if(tournament2[(2*i)]-&gt;no_of_win &lt; tournament2[(2*i)+1]-&gt;no_of_win)
              {
                  tournament2[(2*i)]-&gt;no_of_win = 0;
                  tournament2[(2*i)+1]-&gt;no_of_win = 0;
                  tournament3[i] = tournament2[(2*i)+1];
              }
          }
          Refree number7(tournament3[0], tournament3[1]);
          number7.decision2();
          if(tournament3[0]-&gt;no_of_win &gt; tournament3[1]-&gt;no_of_win)
          {
              cout&lt;&lt;tournament3[0]-&gt;c_name&lt;&lt;endl;
          }
          else if(tournament3[0]-&gt;no_of_win &lt; tournament3[1]-&gt;no_of_win)
          {
              cout&lt;&lt;tournament3[1]-&gt;c_name&lt;&lt;endl;
          }
  
      };
      //============main.cpp===========
      string user_input;
          getline(cin, user_input);
  
          std::vector&lt;std::string&gt; vec;
  
          istringstream iss(user_input);
          copy(istream_iterator&lt;string&gt;(iss),
          istream_iterator&lt;string&gt;(),
          back_inserter(vec));
          Computer *players[8];
          for(int i=0; i&lt;8; i++)
          {
              if(vec.at(i)=="Avalanche")
              {
                  players[i] = new Avalanche(5);
                  players[i]-&gt;c_name = "Avalanche";
                  //cout&lt;&lt;"Avalanche: "&lt;&lt;players[i]-&gt;c_game&lt;&lt;endl;
              }
              else if(vec.at(i)=="Bureaucrat")
              {
                 players[i] = new Bureaucrat(5);
                 players[i]-&gt;c_name = "Bureaucrat";
                 // cout&lt;&lt;"Bureaucrat: "&lt;&lt;players[i]-&gt;c_game&lt;&lt;endl;
              }
              else if(vec.at(i)=="Toolbox")
              {
                  players[i] = new Toolbox(5);
                  players[i]-&gt;c_name = "Toolbox";
                 // cout&lt;&lt;"Toolbox: "&lt;&lt;players[i]-&gt;c_game&lt;&lt;endl;
              }
              else if(vec.at(i)=="Crescendo")
              {
                  players[i] = new Crescendo(5);
                  players[i]-&gt;c_name = "Crescendo";
                 // cout&lt;&lt;"Crescendo: "&lt;&lt;players[i]-&gt;c_game&lt;&lt;endl;
              }
              else if(vec.at(i)=="Paperdoll")
              {
                  players[i] = new Paperdoll(5);
                  players[i]-&gt;c_name = "Paperdoll";
                  //cout&lt;&lt;"Paperdoll: "&lt;&lt;players[i]-&gt;c_game&lt;&lt;endl;
              }
              else if(vec.at(i)=="FistfullODollars")
              {
                  players[i] = new Fistfullodollars(5);
                  players[i]-&gt;c_name = "FistfulloDollars";
                  //cout&lt;&lt;"FistfullOdollars: "&lt;&lt;players[i]-&gt;c_game&lt;&lt;endl;
              }
          }
          Tournament *thebigdayin = new Tournament(players[0], players[1], players[2], players[3], players[4], players[5], players[6], players[7]);
          thebigdayin-&gt;decision();
  </code></pre>