我试图在不同的时间点编写一个计算球高度的程序,但是每当我试图编译时,我都会得到错误的LNK2019。而且,它一直告诉我,我的双打将转换为国家统计局,但我不知道为什么。
1可能丢失的data 1>c:\users\oliver\documents\visual studio 2015\projects\parabola\parabola\parabola.cpp(22):警告C4244:‘1>c:\users\oliver\documents\visual’:从'double‘到'int’的转换,可能丢失的data 1>c:\users\oliver\documents\visual studio C4244警告C4244:‘参数’:从'double‘到'int’的转换,可能丢失的data 1>c:\users\oliver\documents\visual studio 2015\projects\parabola\parabola\parabola.cpp(24):警告C4244:‘1>c:\users\oliver\documents\visual’:从'double‘到'int’的转换,可能丢失的data 1>c:\users\oliver\documents\visual studio C4244警告C4244:‘参数’:从'double‘到'int’的转换,可能丢失的data 1>c:\users\oliver\documents\visual studio 2015\projects\parabola\parabola\constants.h(2):警告C4244:“参数”:从“double”到“int”的转换,可能丢失的数据1> Functions.cpp 1>c:\users\oliver\documents\visual studio C4244警告C4244:“初始化”:从“双”到“int”的转换,可能丢失的数据1>生成代码.1>Parabola.obj : error LNK2019:未解决的外部符号"double __cdecl ballHeight(int,double)“(?ballHeight@@YANHN@Z)在函数_main 1>C:\Users\OLIVER\Documents\Visual Studio 2015\Projects\Parabola\Debug\Parabola.exe :致命错误LNK1120: 1未解决的外部构建:0成功,1失败,0最新的0跳==========中引用。
这是所有的文件。
Main
#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;
}FUNCTIONS.h
#pragma once
#include "stdafx.h"
int main();
double getHeight();
double ballHeight(int seconds, double bHeight);
void tryAgain();CONSTANTS.h
#pragma once
const int gConstant = 9.8;发布于 2015-12-04 07:35:50
double ballHeight(double bHeight, int seconds)与
double ballHeight(int seconds, double bHeight)签名是不同的。
https://stackoverflow.com/questions/34083116
复制相似问题