我是编码的新手。我正在尝试学习如何使用void函数,但正确执行此操作后不会弹出任何消息。一点都不喜欢
我正在使用代码块,而buckey的教程视频显示它对他有用。我编写的代码运行了,但没有任何结果。好像我的外套里什么都没有。
如果您好奇的话,这里是Buckey教程的链接。
https://www.youtube.com/watch?v=bsWWHo4KDHE&list=PLAE85DE8440AA6B83&index=9
#include <iostream>
using namespace std;
void ItDoesSomething();
int main()
{
void ItDoesSomething();
return 0;
}
void ItDoesSomething()
{
cout << "I like rain in Africa."<< endl;
}
请帮助。当我运行它时什么也没出来。我只想学习如何正确使用void功能。
答案 0 :(得分:1)
您不调用该函数,只需声明它:
void ItDoesSomething(); // Declare the function
称呼它
ItDoesSomething(); // Call the function