指定时功能不会重复
Function does not repeat when specified
我做了一个函数" 1",我想问用户"您想重复功能" 1"?",我在做什么错?这是我的代码:
#include <cstdlib>
#include <iostream>
using namespace std;
void temperature()
{
float c,f;
cout<<"Áveskite temperatørà pagal Celsijø: ";
cin>>c;
f=(c*1.8)+32;
cout<<"Temperatûra pagal Farenheità: ";
printf("%2.2f", f);
cout<<endl;
}
int main()
{
setlocale(LC_ALL,"Lithuanian");
temperature();
char isjungti;
cout<<"Paversti dar vienà temperatûrà?(T)";
cin>>isjungti;
if(isjungti == 'T' || 't')
{
return temperature(); //I get an error here.
}
system("PAUSE");
return EXIT_SUCCESS;
}
感谢您的帮助。
return
将退出函数范围。使用
while (isjungti == 'T' || isjungti == 't') {
temperature()
}
或类似。
isjungti == 'T' || 't'
肯定是错误的。另外,return temperature();
,因为temperature()
返回void
。
您可能的意思是:
if(isjungti == 'T' || isjungti == 't')
{
temperature(); //I get an error here.
}
main()是int,您的函数不会返回任何内容。从错误的行中剥离"返回"只是为了调用函数并在返回值上读取。
相关文章:
- 在执行其他功能的同时播放动画(LED矩阵和Arduino/ESP8266)
- 多态性和功能结合
- Ardunio UNO解决了多个重叠的定时器循环
- 带内存和隔离功能的SQLite
- 在CMakeLists.txt的安装功能中使用.cmake文件有什么用
- 类模板的成员功能的定义在单独的TU中完全专业化
- 有没有一种方法可以创建一个带有哈希表的数据库,该哈希表具有恒定时间查找功能
- 如何在C++中获得"静态纯虚拟"功能?
- 两个文件使用彼此的功能-如何解决
- 我应该实现右值推送功能吗?我应该使用std::move吗
- QML按钮点击功能执行顺序
- 无法理解此 return 语句的功能,没有它就会发生运行时错误
- 有没有可能有一个只有ADL才能找到的非好友功能
- 功能样式转换从 'int' 到 'ItemType' 的匹配转换
- 定时功能:双返0毫秒
- 为什么我应该使用SetTimer功能,而不是多媒体定时器服务的应用程序不需要高分辨率定时
- C++ 蛇克隆:定时器功能忽略给定的停止时间并停止在自己的固定时间
- 在VC++中设计定时器功能
- Boost::asio如何实现定时数据包发送功能
- 试图了解如何设置定时器功能的工作在MFC