c++ - 为什么这行不通?第二个功能不会注册?

标签 c++ visual-studio-2010

<分区>

#include <iostream>
#include <iomanip>
using namespace std;

int main ()
{
double a;
double b;
a =(3.0);
b =(5.0);
cout << "  " << fixed << setprecision (1) << a << "\n" << endl;
cout << "* " << fixed << setprecision (1) << b << "\n" << endl;
cout << "------" << endl;
cout << fixed << setprecision (2) << a*b << "\n" << endl;

system("PAUSE");

return 0;
}

int calculate ()
{
   double a;
   double b;
   double c;
   a = (7.1);
   b = (8.3);
   c = (2.2);
   cout << fixed << setprecision(1) << endl;
   cout << "  " << fixed << setprecision (1) << a << "\n" << endl;
   cout << "* " << fixed << setprecision (1) << b << "\n" << endl;
   cout << "- " << fixed << setprecision (1) << c << "\n" << endl;
   cout << "------" << endl;
   cout << std::setprecision(2) << (a * b) - c << "\n" << std::endl;

system("PAUSE");

return 0;
}

请不要只是告诉我阅读介绍 C++ 的书或以模糊的方式告诉我我的问题,我有 1 个,它遗漏了像这样的非常小的细节。可悲的是,我一直在努力让它工作一个小时,哈哈。

输出:

1>------ 构建开始:项目:1.2,配置:调试 Win32 ------ 1>LINK : error LNK2001: 未解析的外部符号 _mainCRTStartup 1>c:\users\justin\desktop\1.2\Debug\1.2.exe : fatal error LNK1120: 1 Unresolved external ========== 构建:0 成功,1 失败,0 最新,0 跳过 ==========

最佳答案

您需要将源文件添加到 Visual Studio 项目中。

在解决方案资源管理器中右键单击“1.2”项目,选择“添加/现有项目...”,然后导航到源文件。

然后再次尝试构建。

构建工作后,您可以担心将对 calculate() 函数的调用集成到程序中(到那时可能会容易得多)。

关于c++ - 为什么这行不通?第二个功能不会注册?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12487002/

相关文章:

windows - 如何从 Visual C++ 应用程序执行另一个程序

c++ - 从模板基类继承构造函数而不重复模板参数?

javascript - 在 asp.net 中的页面加载事件之前从 Javascript 获取值

c++ - 未记录的功能不应在列表中可见/显示 - 仅为记录的实体发布文档

c# - Visual C# 在调用包装的 C++\CLI dll 中的 Lapack 时抛出 System.AccessViolationException

c++ - 在c++中应该使用什么代码代替getche

c# - WPF C# 输入框

visual-studio-2010 - 禁用 Visual Studio 自动 id 重命名

C++甚至在进入函数之前就出现段错误

c++ - std::future::get() 不捕获异步函数抛出和程序崩溃时的异常