📄 product1.cpp
字号:
/*
This program compiles but doesn't run.
See product2.cpp for the complete program.
*/
#include <iostream>
#include <string>
using namespace std;
class Product
{
public:
Product();
void read();
bool is_better_than(Product b) const;
void print() const;
private:
};
int main()
{
Product best;
bool more = true;
while (more)
{
Product next;
next.read();
if (next.is_better_than(best)) best = next;
cout << "More data? (y/n) ";
string answer;
getline(cin, answer);
if (answer != "y") more = false;
}
cout << "The best value is ";
best.print();
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -