我介紹計算機科學類只是覆蓋在本週的功能,並檢查「未解決的外部符號」的主要線索後,我想,不是3未解決的外部符號(初學C++)
a)你聲明的功能,但從來沒有叫他們以後主要
b)你是缺少正確的庫
我只是不知道它是哪一個或如何正確地去了解它。另外,我認爲我的邏輯在calcSideC塊中有一些小缺陷,儘管我不確定
#include <iostream>
#include <cmath>
using namespace std;
float getSide();
float calcSideC(float sideA, float sideB, float total);
void displaySideC(float sideC);
int main()
{
{
float sideA = 0.0;
float sideB = 0.0;
float total = sideA + sideB;
float sideC = sqrt(total);
sideA = getSide();
sideB = getSide();
sideC = calcSideC(sideA, sideB, total);
displaySideC(sideC);
return 0;
}
float getSide();
{
float sideA;
cout << "Enter two sides of a right triangle.\n\n" << "Side A: \n" << "Please enter the dimension: ";
cin >> sideA;
return sideA;
}
float getSide();
{
float sideB;
cout << "\n\n" << "Side B: \n" << "Please enter the dimension: ";
cin >> sideB;
return sideB;
}
float calcSideC(float sideA, float sideB, float total);
{
float sideA;
float sideB;
float total;
float sideC;
pow(sideA, 2);
pow(sideB, 2);
float sqrt(total);
return sideC;
}
void displaySideC(float sideC);
{
float sideC;
cout << "The dimension of Side C is: " << sideC;
}
system("pause");
return 0;
}
你永遠*定義*您的功能,如'getSide '和其他人。因此鏈接器錯誤。 – AnT