视觉C++不确定我在做什么来获得这些错误
visual C++ not sure what I am doing to get these errors
# include "stdafx.h"
# include <iostream>
using namespace std;
void Input(double cell_num, double relays, int & call_length);
void Output(double cell_num, double relays, double call_length, double net_cost, double call_tax, double total_cost);
void Process(double relays, double call_length, double net_cost, double call_tax, double total_cost);
void Input(double cell_num, double relays, double call_length)
{
cout << "Enter your seven digit cell phone number.n";
cin >> cell_num;
cout << "Enter the number of relay stations.n";
cin >> relays;
cout << "Enter the number of minutes used to the nearest minute.n";
cin >> call_length;
}
void Output(double cell_num, double relays, double call_length, double net_cost, double call_tax, double tax_rate, double total_cost)
{
if ((relays >= 1) && (relays <= 5))
tax_rate = .01;
else if ((relays >= 6) && (relays <= 11))
tax_rate = .03;
else if ((relays >= 12) && (relays <= 20))
tax_rate = .05;
else if ((relays > 21) && (relays <= 50))
tax_rate = .08;
else if (relays > 50)
tax_rate = .12; // lines 39-48 used to assign taxation.
net_cost = (relays / 50 * .4 * call_length);
call_tax = net_cost * tax_rate;
total_cost = net_cost + call_tax;
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
}
void Process(double cell_num, double relays, double call_length, double net_cost, double call_tax, double total_cost)
{
cout << "Callers Info Calculated outputn";
cout << "============================================n";
cout << "Cell phone: " << cell_num;
cout << "nRelay Stations: " << relays;
cout << "nMinutes Used: " << call_length;
cout << "nNet Cost: " << net_cost;
cout << "nCall Tax: " << call_tax;
cout << "nTotal cost: " << total_cost;
}
int main()
{
double cell_num=0;
double relays = 0;
double call_length = 0;
double net_cost = 0;
double call_tax = 0;
double tax_rate = 0;
double total_cost = 0;
Input(cell_num, relays, call_length);
Process(relays, call_length, net_cost, call_tax, total_cost);
Output(cell_num, relays, call_length, net_cost, call_tax, total_cost);
return 0;
}
一般功能很新,不了解我遇到的错误。 我有一个工作程序,但我试图将其组织成函数,但我无法让它正常工作。如果有人可以帮助我并解释为什么需要某些更改以便我将来可以修复,我将不胜感激。
你声明过程需要 5 个双打:
void Process(double relays, double call_length, double net_cost, double call_tax, double total_cost);
但是你把它定义为 6 个双打:
void Process(double cell_num, double relays, double call_length, double net_cost, double call_tax, double total_cost)
因此,当您调用 5 双精度版本时,编译器会看到它已声明(这是编译器需要的全部内容(,但是当链接器去查找定义时,它找不到它。
输出也存在相同的样式问题。
首先删除第一行:
# include "stdafx.h"
请参阅此答案以了解为什么要删除它:致命错误:"stdafx.h"文件未找到
接下来,你的两个函数调用缺少参数,在main((中你调用了:
Process(relays, call_length, net_cost, call_tax, total_cost);
Output(cell_num, relays, call_length, net_cost, call_tax, total_cost);
输出需要 7 个参数,但你只传递了 6 个参数。
除了你的函数声明与你的定义不匹配(在这种情况下实际上并不重要(之外,你的 Input 定义不接受引用或指针,因此你通过值传递,你不会从中得到任何东西。
由于您的函数在使用之前就已定义,因此您实际上不需要顶部的声明。 但是您的调用必须与您的定义匹配,而它们不符合。 因此,未解决的功能错误。
相关文章:
- 警告处理为错误这里有什么问题
- 线程,如果else语句,都是错误的上下文切换后,会发生什么
- 0-1背包代码中的错误.我的代码中有什么错误
- 是什么导致了Unity 3D中的"错误线程异常"?
- 在C++中样板"冷/never_inline"错误处理技术的最佳方法是什么?
- .h 和.cpp文件分离时出错,但仅使用 .h 文件时没有错误.我做错了什么?
- 你能解释一下什么运行时错误是如何解决它的吗?
- 在C++中创建队列 - 什么是 malloc 错误?
- 当我从下面的代码中删除关键字 virtual 时,它可以正常工作,否则会出现错误。在这里"virtual"字的意义是什么?
- 没有可行的过载'='错误,可能导致这种情况的原因是什么?
- 给定一个整数数组,需要在Max_Heap上运行操作。得到错误"segmentation fault",有什么想法吗?(C++)
- 这个失败的测试是将零添加到空指针未定义的行为、编译器错误还是其他什么?
- Clang 8 带有静态 constexpr 和数组的链接器错误 - 错误是什么以及如何解决它?
- 我遇到了黑客排名中的问题"TWO STRINGS"的三个测试用例的分段错误。原因是什么?
- 什么会导致LNK2019 VisualStudio中的错误?
- 导致hash_map错误的原因是什么,如何修复它?
- 使用STL对用户输入数组进行排序的错误有什么解决方案吗?
- 我正在尝试学习如何在 c++ 中传递指针,但出现错误:没有用于调用"test"的匹配函数。我做错了什么?
- 当我选择大于 720 的矩阵大小时,程序退出并显示错误代码.可能是什么原因?
- Makefile错误:什么都不做