简体   繁体   中英

Get a double to store a value C++

Just wanted to know what is wrong with this. Double in is suppose to be set to 50 if it is NULL. Then after it is set to 50 it gets subtracted with the user input of double bbet with the analyze(). But after it loops it self it still thinks double in is NULL. Can any one point me in the right direction to get in to remember the value it subtracted its self with.

#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;
}

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM