我想知道为什么这不会识别向量为空并提供具有双启动的向量 pStack?该程序的目标只是在堆栈向量为空时第一次简单地提供 50。然后,一旦提供了起始金额,它应该减去用户输入(下注)。然后,由于它是一个向量,它会将旧总和带到第二次,因此可以再次用用户输入的 bet 减去它。
#include <iostream>
#include <string>
#include <vector>
using namespace std;
class Bet
{
public:
void set_stack(double n);
void set_bet(double n);
double analyze();
double get_stack();
double get_bet();
private:
double pCount;
double bet;
};
double Bet::analyze()
{
double p = pCount;
double b = bet;
double z = p - b;
return z;
}
void Bet::set_bet(double n)
{
bet = z;
}
double Bet::get_bet()
{
return bet;
}
void Bet::set_stack(double n)
{
pCount = n;
}
double Bet::get_stack()
{
return pCount;
}
double start = 50; // Start needs to go inside of pStack
double bbet;
vector<double> pStack(1);
int main()
{
bool con = true;
while(con){
if(pStack.empty()){
pStack.push_back(start); // pStack should be supplied with start when empty
}
double adjst = pStack[0];
Bet rr;
rr.set_stack(adjst);
pStack.clear();
cout << "Enter min 1 Bet: ";
cin >> bbet;
rr.set_bet(bbet);
double aStack = rr.analyze();
pStack.push_back(aStack);
rr.set_stack(aStack);
double newStack = rr.get_stack();
cout << "Stack: " << newStack << endl;
cout << "Bet: " << bbet << endl;
}
system("pause");
return 0;
}