fork(2) download
  1. #include <iostream>
  2. #include <array>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8. char o='A';
  9.  
  10. char PlayField3[5][5] = {{o,o,o,o,o},{o,o,o,o,o},{o,o,o,o,o},{o,o,o,o,o},{o,o,o,o,o}};
  11. std::array<std::array<char,5>, 5> PlayField2{{{o,o,o,o,o},{o,o,o,o,o},{o,o,o,o,o},{o,o,o,o,o},{o,o,o,o,o}}};
  12.  
  13. // or:
  14. std::array<std::array<char,5>, 5> PlayField;
  15. for(auto& row : PlayField){
  16. for(auto& place : row){
  17. place=o;
  18. }
  19. }
  20. cout << PlayField[2][3] << std::endl;
  21. // or:
  22.  
  23. std::vector<std::vector<char>> PlayFieldVec(5,std::vector<char>(5,o));
  24. cout << PlayFieldVec[2][3] << std::endl;
  25.  
  26. }
  27.  
  28. // with char[][] like this:
  29.  
  30. class field
  31. {
  32. private:
  33. char PlayField[5][5];
  34. public:
  35. char o = 'o';
  36. field() : PlayField{ { o, o, o, o, o }, { o, o, o, o, o }, { o, o, o, o, o }, { o, o, o, o, o }, { o, o, o, o, o } }
  37. {}
  38. };
  39.  
Success #stdin #stdout 0s 3272KB
stdin
Standard input is empty
stdout
A
A