递归函数不返回指定的值。
double load_price(){ double price; Goods * tempGd = new Goods(); cin >> price; while (!cin) { cin.clear();#undef max std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); cout << endl; cout << "You didn't enter a number. Do so, please: "; cin >> price; } // endwhile if (!tempGd->set_price(price)) { cout << endl; cout << "The price " << red << "must not" << white << " be negative." << endl; cout << "Please, insert a new price: "; load_price(); } else { delete tempGd; return price; }}
bool Goods::set_price(double price){ if (price> 0) { priceSingle_ = price; priceTotal_ = price* amount_; return true; } return false;}
30秒到达战场
侃侃无极
相关分类