我得到这个错误: error LNK2019: unresolved external symbol "double __cdecl calculateRetail(double,double)" ([email protected]@[email protected]) referenced in function _main 1>c:\users\100236744\documents\visual studio 2010\Projects\Item sales price calculator\Debug\Item sales price calculator.exe : fatal error LNK1120: 1 unresolved externals
错误LNK2019:无法解析的外部符号 “双__cdecl calculateRetail(双,双)”
我很新的C++。
// FILE: Price markup calculator.cpp
// PROGRAMMER: Karolina Sabat CPSC 1103 Section: S11
// Program which calculates the retail cost of an item based on wholesale cost and mark up percentage.
// Calculates the total interest paid based on the annual interest rate.
#include <iostream> // For cin, cout
#include <iomanip> // For setw, setprecision
using namespace std;
// FUNCTION PROTOTYPES
void getData (double &, double &); // Receives USER INPUT - Wholesale cost & percentage markup
double calculateRetail(double, double); // Calculates retail price
void Display (double, double, double); // Displays results: Wholesale cost, markup percentage, retail price
int main()
{
// VARIABLES
double wholesale_cost = 0; // Wholesale item cost - USER INPUT
double markup_percent = 0; // Markup percentage
double retail_price = 0; // Calculated retail cost
// FUNCTION CALL 1: Wholesale cost - USER INPUT
getData(wholesale_cost, markup_percent);
// FUNCTION CALL 2: Retail price - CALCULATION
calculateRetail(wholesale_cost, markup_percent);
// FUNCTION CALL 3: Display Wholesale price, markup percentage, retail price - OUTPUT
Display(wholesale_cost, markup_percent, retail_price);
// PROGRAM MADE BY - OUTPUT
cout << endl << endl;
cout << " Written by: Karolina Sabat - CPSC 1103 - Section: S11" << endl << endl;
return 0;
}
// FUNCTION 1: GetData
void getData (double &wholesale_c, double &markup_p)
{
// Wholesale cost - USER INPUT
cout << " Please enter the item's wholesale cost: $ ";
cin >> wholesale_c;
// Wholesale cost - INVALID ENTRY
while (wholesale_c < 0)
{
cout << endl;
cout << " Please enter a wholesale cost greater than 0." << endl;
cout << " Item's wholesale cost: $ ";
// Will clear characters
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
cin >> wholesale_c;
}
// Wholesalecost - VALID
// Markup percentage - USER INPUT
cout << "Please enter the markup percentage: % " ;
cin >> markup_p;
// Markup percentage - INVALID
while (markup_p < 0)
{
cout << " ERROR: INVALID INPUT." << endl;
cout << " Please enter a markup percentage greater than 0." << endl;
cout << " Markup percentage: % ";
// Will clear characters
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
cin >> markup_p;
}
}
// FUNCTION 2: CalculateRetail
double CalculateRetail (double wholesale_c, double markup_p)
{
// VARIABLES
double markup_amount;
double retail_price;
// CALCULATIONS
markup_amount = (wholesale_c * markup_p)/100;
// Markup amount
retail_price = wholesale_c + markup_amount;
return retail_price;
}
// FUNCTION 3: Display
void Display (double wholesale_cost, double markup_percent, double retail_price)
{
// Title - OUTPUT
cout << endl;
cout << " WHOLESALE COST: " << setw(10) << "PRICE MARKUP %: " << setw(10) << "RETAIL PRICE" << endl;
cout << " ________________________________________________________________________________" << endl;
cout << endl;
// NUMBER FORMATING
cout << setprecision(2) << fixed << showpoint;
// Results - OUTPUT
cout << " " << wholesale_cost << setw(10) << markup_percent << setw(10) << retail_price;
}
[错误LNK2019解析外部符号]的可能重复(http://stackoverflow.com/questions/12297952/error-lnk2019-unresolved-external-symbol)和约三十多人。搜索“错误LNK2019:无法解析的外部符号”可能会引发许多以往问题的链接。在发布之前先进行基础研究是很好的。 –
我没有搜索过这个论坛,我明白这个错误,但是一小时后我的代码找不到错误。我没有看到大写错误。其他人的编码错误不能帮助我。 – tinywolves
好的,它应该是关闭的话题,因为“这个问题是由不能再现的问题引起的,或者是一个简单的印刷错误**。虽然类似的问题可能在这里讨论,但这个问题已经解决了以不太可能帮助未来读者的方式,这通常可以通过识别并密切检查在发布之前重现问题所需的最短程序来避免。“ –