Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5848139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:49:01+00:00 2026-05-22T12:49:01+00:00

I’ve been working on this project for a while, it’s a new language for

  • 0

I’ve been working on this project for a while, it’s a new language for me but I had a partner with experience who kinda ditched me. Anyways, right now I’m having trouble with getting the text from one object to another. I instantiate an object in the game class, then try to get it and save it to another object in the main class but when I get the object it’s empty! I don’t know what’s going on here and I just can’t seem to figure it out.

but the part that isn’t working is in the display method when I try to draw the questions text:

drawText((WinWidth/2)-225, (WinHeight/2) - 90, curQuestion.question.c_str());

curQuestion is created at the top but instantiated in the mouse method:

curQuestion = g.getQuestion(col,row);

and here’s the game class (which is in Cc.h)

class Game {
public:
    Game(bool);
    void initQuestions();
    Question getQuestion(int, int);
    string getQuestionText(int, int);

private:
    Question questions[5][5];
};

Game::Game(bool m)
{
    mp = m;
    initQuestions();
}

void Game::initQuestions()
{
    bool hasDouble = false;
    srand( time(NULL));
    int blarg = rand() % 25 + 1;
    fstream questionFile;
    questionFile.open("questions.txt", ifstream::in);
    int cur = 0;
    for(int c = 0; c < 5; c++)
    {
        for(int r = 0; r < 5; r++)
        {
            char * q = new char[256];
            char * a = new char[256];
            questionFile.getline(q,256);
            questionFile.getline(a,256);
            questions[c][r] = Question(c,r, false, q, a);
            cout << questions[c][r].question.c_str() << questions[c][r].answer.c_str();
        }
    }
    questionFile.close();
}

Question Game::getQuestion(int c, int r)
{
    return questions[c][r];
}

string Game::getQuestionText(int c, int r)
{
    return questions[c][r].question;
}

Note: the cout called in the game method does return exactly what it should!

Question class:

class Question {
public:
    int col;
    int row;
    bool dailyDouble;
    string question;
    string answer;
    int value;
    Question();
    Question(int, int, bool, string, string);
    bool checkAnswer(string);
    string getQuestion();
};

Question::Question() { }

Question::Question(int c, int r, bool d,string q, string a)
{
    col = c; row = r; dailyDouble = d; question = q, answer = a;
    cout << "TEST> Q: " << question << ", A: " << answer << endl;
    if(d)
        value = r * 200 * 2;
    else
        value = r * 200;
}

bool Question::checkAnswer(string answer)
{
    if(answer.find("What is") && answer.find(answer))
        return true;
    return false;
}

string Question::getQuestion() {
    return question;
}

I really can’t understand what’s going wrong here, any help is greatly appreciated. I hope that once I figure out what’s going wrong here I’ll be able to finish on my own!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T12:49:02+00:00Added an answer on May 22, 2026 at 12:49 pm

    I tried your code on my computer, it seems that both the Question class and the Game class is correct, I also tried the Game::getQuestion() and the Game::getQuestionText() method, it’s all correct, and returns the proper value.

    By the way, there are no pointer members in the Question Class and the Game Class, so there is no need to write a copy constructor and a operator=() overload method.

    Maybe you can check if the col and row you passed in g.getQuestion(col,row) is right or not.

    Sorry have to post an answer here, cause I don’t know how to add a comment to your question.

    wish this will help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I'm looking for suggestions for debugging... If you view this site in Firefox or
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I want to count how many characters a certain string has in PHP, but
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.