问题描述
我在这里搞砸了什么?代码中没有硬编码的值,这就是为什么我的所有提示都是常量的原因.我们还必须调用用户定义的函数来验证输入.
What have I screwed up here? There can be no hard coded values in the code which is why all my prompts are constants. We also have to call a user defined function to verify input.
我在编译时遇到以下错误-未定义对WinMain的引用,[错误] ID返回1退出状态我正在使用Dev C ++作为IDE
Im getting the following error when I compile -- undefined reference to WinMain, [Error] Id returned 1 exit status I'm using Dev C++ as an IDE
#include <iostream> //for I/O
#include <iomanip> //for formatting output
using namespace std;
const string PROGRAM_DESCRIPTION = "Program will calculate the amount "
"accumulated every month you save, \nuntil you reach your goal. ";
const string ENTER_DOLLAR_AMOUNT_MONTHLY = "Enter the dollar amount to be "
"saved each month: ";
int main()
{
double dollarSavedPerMonth;
//displays program description
cout << PROGRAM_DESCRIPTION << endl << endl;
//Prompts user to enter dollar amount to be saved monthly, will validate
//input by calling VerifyDollar
dollarSavedPerMonth = VerifyDollar(ENTER_DOLLAR_AMOUNT_MONTHLY);
cout << endl;
return 0;
}
double VerifyDollar (string Prompt)
{
const string INVALID_DOLLAR_AMOUNT = "Invalid amount, re-enter monthly "
"savings amount.";
double dollarSaved;
cout << Prompt;
cin >> dollarSaved;
while (dollarSaved < 5 || dollarSaved > 5000)
{
cout << INVALID_DOLLAR_AMOUNT;
cout << endl;
cout << Prompt;
cin >> dollarSaved;
}
return dollarSaved;
}
推荐答案
您确实确实在该代码中的任何地方都缺少WinMain()函数.
You do indeed lack a WinMain() function anywhere in that code.
如果内存可以很好地为我服务,则WinMain()是Win32 GUI应用程序的入口点.我假设您的IDE要求您提供某种项目类型",并且您要求的是Windows应用程序而不是控制台应用程序.
If memory serves me well, WinMain() is the entry point for a Win32 GUI app. I am assuming your IDE asked you for a "project type" of some sort, and you asked for a Windows app instead of a Console one.
在此假设下,项目中的某些内容被配置为调用WinMain(),而您未定义它,因此出现链接器错误.
Under that assumption, something in your project is configured to call WinMain(), which you did not define, hence the linker error.
这篇关于未定义对WinMain的引用,[错误] ID返回1退出状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!