vendredi 23 octobre 2015

Calling members of an array in c++ to display to console

I'm trying to have my program go through an array and print a random question. Each question comes with four answers and I'm trying to get it to print them as well. However when I try to get it to pull the specific answers for whichever random question it chooses it shoots an error. Any ideas?

    if (choice == 1)
        {
            enum fields{ QUESTS, ANS_1, ANS_2, ANS_3, ANS_4, NUM_FIELDS };
            string QUEST[NUM_QUEST][NUM_FIELDS] =
            {
                { "What course is this?", "A)C++", "B)DID", "C)Intro to Game", "D)Yoga" },
                { "Who am I?", "A)Bill", "B)Nye", "C) 24601", "D)No one" },
                { "Are you actually reading this?", "A) Yes", "B)No", "C)Maybe", "D)Who wants to know?" },
                { "Will this program work?", "A)Of course it will!", "B)It might", "C)Are you kidding me?", "D)Gods only know." },
                { "Where would I rather be?", "A)Home", "B)Europe", "C)Anywhere but here", "D)All of the above" }
            };
            srand(static_cast<unsigned int>(time(0)));
            int randomQuest = (rand() % NUM_QUEST);
            string question = QUEST[randomQuest][QUESTS];
            string print = question;
            string printAns1 = QUEST[ANS_1];
            string printAns2 = QUEST[ANS_2];
            string printAns3 = QUEST[ANS_3];
            string printAns4 = QUEST[ANS_4];
        }

Quest[ANS_1] and the others below it are what have an error. It is telling me-

"no suitable constructor exists to convert from "std::string [5]" to "std::basic_string, std::allocator>"




Aucun commentaire:

Enregistrer un commentaire