0

只是想知道这有什么问题。如果双输入为 NULL,则假定将其设置为 50。然后在它设置为 50 之后,它会被用户输入的 double bbet 与analyze() 相减。但是在它自我循环之后,它仍然认为 double in 是 NULL。谁能指出我正确的方向来记住它减去自己的值。

#include <iostream>
#include <string>


using namespace std;


class Bet
{
public:
void set_stack(double n);
void set_bet(double n);
void analyze();
double get_stack();
double get_bet();

private:
double pCount;
double bet;
};

void Bet::analyze()
{
double p = pCount;
double b = bet;
double z = p - b;

pCount = z ;
}

void Bet::set_bet(double n)
{
double z = n;
bet = z;

}
double Bet::get_bet()
{
return bet;
}


void Bet::set_stack(double n)
{

double z = n;

pCount = z;
}


double Bet::get_stack()
{
double p = pCount;
double b = bet;


double z = p - b;

return z;
}
double bbet;
double in ;
double* inV;

int main()
{


bool con = true;
while(con){
double start = 50;


if(*inV == NULL){
in = start;}



Bet rr;
rr.set_stack(in);


cout << "Enter min 1 Bet: ";
cin >> bbet;

rr.set_bet(bbet);


double newStack = rr.get_stack();

cout << "Stack: " << newStack << endl;
cout << "Bet: " << bbet << endl;
inV = &in;
}

system("pause");
return 0;
}
4

1 回答 1

0

You want if (inV == NULL) rather than if (*inV == NULL).

于 2013-11-05T04:47:46.530 回答