将鼠标悬停在问题上时与预期">"相关的代码错误
Error in code pertaining to Expected a '>' when hovering over issue
#include <iostream>
using namespace std;
int main()
{
int height, time, count;
double CONST g = 9.8, distance;
cout << "Enter number of seconds the watermelon falls: ";
cin >> time;
cout << "Enter height of bridge: ";
cin >> height;
while (distance < height && count <= time)
{
distance = 0.5 * g * count * count;
cout << count << distance;
count++;
}
}
问题是while语句在单词"time"后面的括号后面,当它悬停在上面时,它说"expected a'>'"。除了使用不同的循环之外,我不确定如何解决这个问题。我是不是错过了什么遗忘的东西?使用Visual Studio Community 2017 IDE C++制作
您的问题都在这一行:double CONST g = 9.8, distance;
首先,CONST
不是(!(保留的c++
字。如果您的g
变量是常量,则应该使用const
:
double const g = 9.8, distance;
但是这一行也不能编译,因为所有的const
变量都必须立即初始化。正如double const
类型下提到的distance
,编译器期望其初始化。
我想,你的意思是让她成为普通的double
变量:
double const g = 9.8;
double distance;
现在代码编译没有任何问题(证明(。
相关文章:
- 警告处理为错误这里有什么问题
- "error: no matching function for call to"构造函数错误
- boost::进程间消息队列引发错误
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 有关插入适配器的错误。[错误]请求从 'back_insert_iterator<vector<>>' 类型转换为非标量类型
- QT在错误的班级中寻找空位
- vector.resize()中的分配错误
- 代码在main()中运行,但在函数中出现错误
- 释放错误后堆使用
- (C++)分析树以计算返回错误值的简单算术表达式
- Project Euler问题4的错误解决方案
- 我的字符计数代码计算错误.为什么
- 从"int*"强制转换为"unsigned int"会丢失精度错误
- 尝试导入pybind-opencv模块时出现libgtk错误
- CMake项目Boost库错误:Boost/config/compiler/gcc.hpp:165:10:致命错误:cs
- 在某些循环内使用vector.push_back时出现分段错误
- 错误,包括&lt; ctype&gt;在原子上使用C 11
- 错误c++visual studio c2227左侧'->;Init';必须指向类/结构/联合/泛型类型
- opencv 2.4.7在iOS错误背景_segm.hpp #include&lt; list&gt;未找到
- 链接器(MinGW的ld v2.23.2)错误,格式:-L<SOMEDIR>-l<lib1-l<l