将一个值递增一定次数
Incrementing a value a certain amount of times
本文关键字:一个 更新时间:2023-10-16
用户在手机和电脑上输入两次。如果它们不同,我需要让它们相等。然后我需要将电脑的时间增加到比手机时钟快1小时5分23秒。
这是我的if语句。
if (!myComputerClock.equalTime(cellPhoneClock))
{
myComputerClock=cellPhoneClock;
cout << " The new time is: n";
cout << " Cellphone: ";
cellPhoneClock.printTime();
cout << endl << endl;
cout << " Computer: ";
myComputerClock.printTime();
}
else
{
myComputerClock.incrementHours();
myComputerClock.incrementMinutes();
myComputerClock.incrementSeconds();
}
您需要决定要同步到哪个时钟,然后为每个setTime
调用编写两行代码。setTime
既不是左值也不是右值(这意味着它既不接受也不返回值),这就是错误告诉您的。
相关文章:
- 如何创建一个CMake变量,除非显式重写,否则使用默认值
- 删除一个线程上有数百万个字符串的大型哈希映射会影响另一个线程的性能
- 为什么两个不同的未命名名称空间可以共存于一个cpp文件中
- 运行同一解决方案的另一个项目的项目
- 挂起和取消挂起一个文件DLL
- 用C++中的一个变量定义一个常量
- 函数向量_指针有不同的原型,我可以构建一个吗
- 在c++中用vector填充一个简单的动态数组
- 如何在选项卡视图Qt中设置一个新项目,并保存以前的项目
- 预处理器:插入结构名称中的前一个行号
- 我在c++代码中生成了一个运行时#3异常
- 我想将一个对T类型的非常量左值引用绑定到一个T类型的临时值
- 从链接列表c++中删除一个项目
- 告诉一个 const char 数组,除了编译时 C 样式的字符串外,它不以 '