c++ - Multiple Errors Building Deck of Cards -


receiving 2 errors trying compile files. (received down vote without explanation; fail see how violates guidelines.)

1) c:\mingw\lib\gcc\mingw32\4.9.3\include\c++\bits\c++0x_warning.h:32:2: error: #error file requires compiler , library support iso c++ 2011 standard. support experimental, , must enabled -std=c++11 or -std=gnu++11 compiler options i attempted add flags in eclipse mars, doesn't seem have worked. thing i'm missing?

2) \deckofcards.h:21:8: error: 'array' in namespace 'std' not name template type this in regards std::array<card,52> cards_; line in deck of cards header file. first time attempting build deck of cards multiple classes...or single class matter if i'm making obvious error apologize.

edit: exact message compiler:

07:56:55 **** incremental build of configuration debug project texasholdem **** info: internal builder used build g++ -o0 -g3 -wall -c -fmessage-length=0 -o texasholdemmain.o "..\\texasholdemmain.cpp"  in file included c:\mingw\lib\gcc\mingw32\4.9.3\include\c++\array:35:0,                  ..\deckofcards.h:11,                  ..\texasholdemmain.cpp:5: c:\mingw\lib\gcc\mingw32\4.9.3\include\c++\bits\c++0x_warning.h:32:2: error: #error file requires compiler , library support iso c++ 2011 standard. support experimental, , must enabled -std=c++11 or -std=gnu++11 compiler options.  #error file requires compiler , library support \   ^ in file included ..\texasholdemmain.cpp:5:0: ..\deckofcards.h:21:8: error: 'array' in namespace 'std' not name template type    std::array<card,52> cards_;         ^  07:56:56 build finished (took 233ms) 

if recompile second time after receiving these errors without changing receive ton more errors everywhere else across multiple files; normal?

main

//texas holdem implementation #include <iostream>  #include "card.h" #include "deckofcards.h"   int main() {       deckofcards deck;      deck.printdeck();      return(0); } 

deckofcards.h

 * deckofcards.h  *  *  created on: jul 8, 2016  *      author:   */  #ifndef deckofcards_h_ #define deckofcards_h_  #include <array>  class deckofcards {      public:         deckofcards();         void printdeck();      private:         std::array<card,52> cards_;   };  #endif /* deckofcards_h_ */ 

card.h

* cards.h  *  *  created on: jul 8, 2016  *      author:  */  #ifndef card_h_ #define card_h_  struct card {      enum suit_type     {         diamonds,         hearts,         spades,         clubs,     } suit;      enum value_type     {          2 = 2,         3 = 3,         4 = 4,         5 = 5,         6 = 6,         7 = 7,         8 = 8,         9 = 9,         ten = 10,         jack = 11,         queen = 12,         king = 13,         ace = 14     } value;      void printcard(); }; 

deckofcards.cpp

#include <iostream> #include "deckofcards.h" #include "card.h" #include <array>   deckofcards::deckofcards() :     cards_     {         {card::diamonds, card::two},         {card::diamonds, card::three},         {card::diamonds, card::four},         {card::diamonds, card::five},         {card::diamonds, card::six},         {card::diamonds, card::seven},         {card::diamonds, card::eight},         {card::diamonds, card::nine},         {card::diamonds, card::ten},         {card::diamonds, card::jack},         {card::diamonds, card::queen},         {card::diamonds, card::king},         {card::diamonds, card::ace},         {card::hearts, card::two},         {card::hearts, card::three},         {card::hearts, card::four},         {card::hearts, card::five},         {card::hearts, card::six},         {card::hearts, card::seven},         {card::hearts, card::eight},         {card::hearts, card::nine},         {card::hearts, card::ten},         {card::hearts, card::jack},         {card::hearts, card::queen},         {card::hearts, card::king},         {card::hearts, card::ace},         {card::spades, card::two},         {card::spades, card::three},         {card::spades, card::four},         {card::spades, card::five},         {card::spades, card::six},         {card::spades, card::seven},         {card::spades, card::eight},         {card::spades, card::nine},         {card::spades, card::ten},         {card::spades, card::jack},         {card::spades, card::queen},         {card::spades, card::king},         {card::spades, card::ace},         {card::clubs, card::two},         {card::clubs, card::three},         {card::clubs, card::four},         {card::clubs, card::five},         {card::clubs, card::six},         {card::clubs, card::seven},         {card::clubs, card::eight},         {card::clubs, card::nine},         {card::clubs, card::ten},         {card::clubs, card::jack},         {card::clubs, card::queen},         {card::clubs, card::king},         {card::clubs, card::ace}     } { }  void deckofcards::printdeck() {      bool first = true;      for(auto card : cards_)     {         if(!first)         {              std::cout << ", ";          }         card.printcard();         first = false;     }  } 

card.cpp

#include<iostream> #include "card.h" #include "deckofcards.h"  card::card() {}  void card::printcard() {      switch(suit)     {      case hearts:         std::cout << "♥";         break;     case diamonds:         std::cout << "♦";         break;     case clubs:         std::cout << "♣";         break;     case spades:         std::cout << "♠";         break;     }     if(value < jack)     {          std::cout << (int)value;     }     else     {         switch(value)         {          case jack:             std::cout << 'j';             break;         case queen:             std::cout << 'q';             break;         case king:             std::cout << 'k';             break;         case ace:             std::cout << 'a';             break;         }     } } 

you have set -std=c++11 flag gnu compiler.

according eclipse forums:

  1. right-click project , go "properties"
  2. go to: c/c++ build -> settings -> tool settings -> gcc c++ compiler -> miscellaneous -> other flags.
  3. put "-std=c++11" @ end.

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -