[英]What is causing me to get the linker error LNK2019?
我正在嘗試編寫一個程序來計算球在各個時間點的高度,但是每當嘗試進行編譯時,都會出現錯誤LNK2019。 而且,它總是告訴我我的雙打被轉換為整數,但是我不知道為什么。
1> ------開始構建:項目:Parabola,配置:調試Win32 ------ 1> Parabola.cpp 1> c:\\ users \\ oliver \\ documents \\ visual studio 2015 \\ projects \\ parabola \\ parabola \\ constants.h(2):警告C4244:'正在初始化':從'double'轉換為'int',可能丟失數據1> c:\\ users \\ oliver \\ documents \\ visual studio 2015 \\ projects \\ parabola \\ parabola \\ parabola.cpp(20):警告C4244:'argument':從'double'轉換為'int',可能丟失數據1> c:\\ users \\ oliver \\ documents \\ visual studio 2015 \\ projects \\ parabola \\ parabola \\ parabola .cpp(21):警告C4244:'自變量':從'double'到'int'的轉換,數據可能丟失1> c:\\ users \\ oliver \\ documents \\ visual studio 2015 \\ projects \\ parabola \\ parabola \\ parabola。 cpp(22):警告C4244:'參數':從'double'轉換為'int',可能丟失數據1> c:\\ users \\ oliver \\ documents \\ visual studio 2015 \\ projects \\ parabola \\ parabola \\ parabola.cpp (23):警告C4244:'argument':從'double'轉換為'int',可能丟失數據1> c:\\ users \\ oliver \\ documen ts \\ visual studio 2015 \\ projects \\ parabola \\ parabola \\ parabola.cpp(24):警告C4244:'argument':從'double'轉換為'int',可能丟失數據1> c:\\ users \\ oliver \\ documents \\ visual studio 2015 \\ projects \\ parabola \\ parabola \\ parabola.cpp(25):警告C4244:'argument':從'double'轉換為'int',可能丟失數據1> Functions.cpp 1> c:\\ users \\ oliver \\ documents \\ Visual Studio 2015 \\ projects \\ parabola \\ parabola \\ constants.h(2):警告C4244:'正在初始化':從'double'轉換為'int',可能丟失數據1>正在生成代碼... 1> Parabola.obj:錯誤LNK2019:函數_main 1> C:\\ Users \\ OLIVER \\ Documents \\ Visual Studio 2015 \\中引用的未解析的外部符號“ double __cdecl ballHeight(int,double)”(?ballHeight @@ YANHN @ Z) Projects \\ Parabola \\ Debug \\ Parabola.exe:致命錯誤LNK1120:1個未解決的外部組件==========生成:0成功,1失敗,0最新,跳過0 ====== ====
這是所有文件。
主要
#include "stdafx.h"
#include <iostream>
#include "FUNCTIONS.h"
#include "CONSTANTS.h"
int main()
{
using namespace std;
cout << "Enter the height of a building (in metres) you wish to simulate dropping a ball off of." << endl;
double bHeight = getHeight(); //Building height is defined
ballHeight(bHeight, 0); //Calls the function ballHeight at various points in time
ballHeight(bHeight, 1);
ballHeight(bHeight, 2);
ballHeight(bHeight, 3);
ballHeight(bHeight, 4);
ballHeight(bHeight, 5);
return 0;
}
職能
#include "stdafx.h"
#include <iostream>
#include "CONSTANTS.h"
#include "FUNCTIONS.h"
double getHeight()
{
using namespace std;
double x = 0;
cin >> x;
return x;
}
double ballHeight(double bHeight, int seconds)
{
using namespace std;
double currentHeight = bHeight - gConstant * seconds * seconds / 2; //Calculates current ball height.
cout << "At " << seconds << " seconds, the ball is at height: " << currentHeight << " metres." << endl; //Returns the ball height.
return 0;
}
功能.h
#pragma once
#include "stdafx.h"
int main();
double getHeight();
double ballHeight(int seconds, double bHeight);
void tryAgain();
常量
#pragma once
const int gConstant = 9.8;
double ballHeight(double bHeight, int seconds)
與
double ballHeight(int seconds, double bHeight)
簽名是不同的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.