그래서이 간단한 C++ 할당 작업을하고 있는데이 인스턴스는 2 개의 인스턴스에 표시됩니다. '오류 5 오류 C2371 :'중계 ': 재정의; 다른 기본 유형 '및'오류 5 오류 C2371 : 'call_length': 재정의; 다른 기본 유형들 '. 나는 1 시간 이상 프로그램을 들여다보고있어이 문제를 보지 못 했으므로 어떤 도움도 부 풀릴 수 없었습니다. 아래이 오류의 원인을 알아낼 수 없습니다 : C2371
코드 : 오류 메시지처럼
#include <iostream> //standard input/output C++ stream library
#include <string> //string library
using namespace std; //using the standard C++ namespace
// function prototypes
void input(string &, int &, int &);
void process(double &, double &, double &, double &, int, int);
void output(string, int, int, double, double, double);
/////////////////////////////////////////////////////////////////
// Function name: input
// Precondition:
// Postcondition:
// Function Description:
////////////////////////////////////////////////////////////////
void input(string & cell_num, int & relays, int & call_length)
{
cout << "Enter your Cell Phone Number: ";
cin >> cell_num;
cout << "Enter the number of relay stations: ";
cin >> relays;
cout << "Enter the length of the call in minutes: ";
cin >> call_length;
}
/////////////////////////////////////////////////////////////////
// Function name:
// Precondition:
// Postcondition:
// Function Description
////////////////////////////////////////////////////////////////7
void process(double & tax_rate, double & call_tax, double & total_cost, double & net_cost, int relays, int call_length)
{
if (1<= relays <=5)
{
tax_rate = .01;
}
else if(6 <= relays <= 11)
{
tax_rate = .03;
}
else if(12<= relays <=20)
{
tax_rate = .05;
}
else if (21<= relays <=50)
{
tax_rate = .08;
}
else if (relays > 50)
{
tax_rate = .12;
}
net_cost = (relays/50.0 * 0.40 * call_length);
call_tax = net_cost * tax_rate/100;
total_cost = net_cost + call_length;
}
/////////////////////////////////////////////////////////////////
// Function name:
// Precondition:
// Postcondition:
// Function Description
////////////////////////////////////////////////////////////////
void output(string cell_num, int relays, int call_length, double net_cost, double total_cost, double call_tax)
{
cout << "*********************************" << endl;
cout << "Cell Phone Number: " << cell_num << endl;
cout << "*********************************" << endl << endl << endl;
cout << "Number of Relay Stations: " << relays << endl;
cout << "Length of Call in Minutes: " << call_length << endl;
cout << "Net Cost of Call: " << net_cost << endl;
cout << "Tax of Call: " << call_tax << endl;
cout << "Total Cost of Call: " << total_cost << endl;
}
int main()
{
string cell_num;
int call_length, relays;
double tax_rate, call_tax, net_cost, relays, call_length, total_cost;
input(cell_num, relays, call_length);
process(tax_rate, call_tax, total_cost, net_cost, relays, call_length);
output(cell_num, relays, call_length, net_cost, total_cost, call_tax);
system("pause");
return 0;
}
이런 상황에서 해결 방법은 다른 사람에게 프로그램을 살펴 보도록하는 것입니다. 그러나 이것은 [SO의 정책] (http://stackoverflow.com/help/dont-ask)과는 거리가 멀다. – 101010
나는 당신이 오류 메시지가 ** 정확히 ** 오류가 무엇인지 말하는 읽어야한다고 생각 : ** 'relays': redefinition; 다른 기본 유형. ** 당신의 코드를 보아라. 그것은 컴파일러가 허용하지 않는다. –