函数未声明简单程序
function not declared simple program
大家好,我相信有人可以帮助我,我对c ++很陌生,试图使这个程序工作。当我从我的主函数调用我的 int 函数时,它告诉我它还没有被声明。我在上面使用了一个原型,所以我不确定为什么它挂断了。我也缺少任何语法吗?提前感谢您的帮助。
#include <iostream>
using namespace std;
int multiFunction(int, int, char);
int main()
{
int value1, value2, OP, total;
total = multifunction(value1, value2);
cout << "Enter a simple math problem I will solve it for you:";
cin >> value1 >> OP >> value2; //gets the three values
cout << "The answer is: " << total << end //displays the answer
return 0;
}
int multiFunction(int A, int B, char OP)
{
int C; //Holds the integer after the operation.
switch(OP)
{
case '+':
C = A + B;
break;
case '-':
C = A - B;
break;
case '*':
C = A * B;
break;
case '/':
C = A / B;
}
return C;
}
您在此处没有传递第三个参数:
total = multifunction(value1, value2); //Prototype is int multiFunction(int, int, char);
multifunction
也与multiFunction
不同。
int a
和int A
是 2 个唯一变量。类似的规则也适用于方法。
拼写
错误:
total = multifunction(value1, value2);
应该是:
total = multiFunction(value1, value2, OP);
主要函数应该是:
int main()
{
int value1, value2, total;
char OP;
cout << "Enter a simple math problem I will solve it for you:";
cin >> value1 >> OP >> value2; //gets the three values
total = multiFunction(value1, value2, OP);
// ^^
cout << "The answer is: " << total << end //displays the answer
return 0;
}
相关文章:
- 显示错误输出的简单数组排序程序
- 简单C++"Hello World"程序的执行时间长
- 而循环:简单的除法程序输出零,不明白为什么
- 为什么一个简单的程序不能立即启动
- 使用简单两相锁定的并发程序
- [[可能]]和[[不太可能]]影响程序汇编的简单示例?
- GDB 8.1 无法在单线程简单程序中跟踪 std::string 变量的值
- 多线程 gtkmm 应用程序最简单的示例
- 我写了一个简单的矢量程序,在其中我得到了以下输出。你能帮我理解它的输出吗?
- 如何使用cmake和Visual Studio 2019编译简单的Windows应用程序?
- 试图解决这个简单的C++程序,但我被困在某个地方
- 我已经安装了用于c++编程的升华3,但在编写了一个简单的程序后,我遇到了以下错误
- 无法编译简单的C++17程序
- 如何设置一个简单的CGAL+Qt程序
- Cmake无法在qt-creater/collect2上编译简单的测试程序:错误:ld
- 令牌之前的简单程序预期标识符'('
- 使用Cmake进行简单的CUDA程序
- 我创建了一个简单的程序,但有些地方不对劲
- 编译简单的多文件类程序时出现未定义的引用错误
- 程序简单,没有调用堆栈,"inpossible"查找错误