获取double来存储值C ++

时间:2013-11-05 04:25:43

标签: c++

只是想知道这有什么问题。如果为NULL,则假设将其设置为50。然后在设置为50之后,使用analyze()的double bbet的用户输入减去它。但是在它循环后它仍然认为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;
}

1 个答案:

答案 0 :(得分:0)

您需要if (inV == NULL)而不是if (*inV == NULL)