Im am making my first game and one of the files just won't compile.


I keep getting this error whenever I try to compile this file (this is only the problem part):

if (answer[0] == 'y')
     {
                   
           if (player->GetGold >= 10)   // PROBLEM
           {
               player->SpendGold(10);
               cout << "You find a nice bed and fall fast asleep.";
               Wait();
           
               cout << "\n(HP and MP restored\n\n";
               cout << "HP: " << player->GetHealth() << " / " << player->GetMaxHealth() << "\n";
               cout << "MP: " << player->GetMana() << " / " << player->GetMaxMana() << "\n";
               player->SetHealth(player->GetMaxHealth());
               player->SetMana(player->GetMaxMana());
               Wait();
           }
           else
           {
               cout << "It looks like you don't have enough gold.\n";
               Wait();
               answer[0] = 'n';
           }
     }

That's not a whole file, so how is one to replicate your problem, or even undertand what we're looking at? Without the variables and function parameters, it's just some code. Which line does the error message point to?

That's not a whole file, so how is one to replicate your problem, or even undertand what we're looking at? Without the variables and function parameters, it's just some code. Which line does the error message point to?

the problem line is:

if (player->GetGold >= 10)

this is only 1 cpp file out of many

You can't compare the string player->GetGold with an integer. If that doesn't solve the problem, give us the information we need to understand the problem. Try reading the sticky posts at the top of the forum for some suggestions.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.