我用她的C ++帮助了一个朋友,但说实话,我们需要一些帮助。
为什么我们总是收到此错误:“MSVCRTD.lib(crtexe.obj):错误LNK2019:未解析的外部 符号主要在函数_ _tmainCRTStartup“
中引用守则如下:
//Maria Delgado (1013725) - Coursework 2 - Program Conducting timber component structural design
#include<iostream>
#include<iomanip>
#include<cmath>
#include<fstream>
#include<string>
using namespace std;
//Variables for Strength Properties in (N/mm2)
//fmk=Bending
//fc90k=Compression Perpendicular
//fvk=Shear
//Calculating Member Size Factor:
void memberSizeFactor(double chosenDepth)
{
if (chosenDepth<150)
kH=pow(150/chosenDepth,0.2);
else
cout<<"Please input a depth less than 150mm"<<endl;
}
//Error message for all negative values entered
double errorNeg()
{
float value=-1;
while (value<0)
{
cout<<"You have entered a negative value. This variable cannot take negative values. Please input positive values!";
cin>>value;
cout<<endl;
}
return value;
}
//Beam Member Class
class beamMember
{
private:
double chosenLength;
double chosenWidth;
double chosenDepth;
double chosenBearingLength;
double serviceClassAbility;
string strengthClass;
public:
beamMember()
{
chosenLength=chosenWidth=chosenDepth=chosenBearingLength=serviceClassAbility=0;
strengthClass="";
}
void beamDimensionsData()
{
cout<<"The following dimensions need to be input into the program:"<<endl;
cout<<"What is the desired beam LENGTH in millimeters?";
cin>>chosenLength;
if(chosenLength<0) chosenLength=errorNeg();
cout<<"What is the desired beam WIDTH in millimeters?";
cin>>chosenWidth;
if(chosenWidth<0) chosenWidth=errorNeg();
cout<<"What is the desired beam DEPTH in millimeters?";
cin>>chosenDepth;
if(chosenDepth<0) chosenDepth=errorNeg();
cout<<"What is the desired beam BEARING LENGTH in millimeters?";
cin>>chosenBearingLength;
if(chosenBearingLength<0) chosenBearingLength = errorNeg();
cout<<"Please insert a strength class of timber e.g.C12 to C50:";
cin>>strengthClass;
cout<<endl<<"Please choose a service class ability for member i.e. 1 or 2 or 3:";
cin>>serviceClassAbility;
cout<<endl;
}
//***************************CALCULATE OVERALL DESIGN LOAD************************************************************
double load(beamMember designBeam)
{
cout<<"Under these circumstances, the beam will be adequate to support a slab."<<endl<<endl;
double qK;
double gK;
double span;
cout<<"Please input the total live load in kN/m2:";
cin>>qK;
cout<<endl;
if (qK<0) qK=errorNeg();
qK=qK*gammaQ;
cout<<"Please input the total dead load in kN/m2:";
cin>>gK;
if (gK<0) gK=errorNeg();
gK=gK*gammaG;
cout<<"Enter the span between the beams in millimeters:";
cin>>span;
while(span<0) span=errorNeg();
cout<<endl;
span=span*(qK+gK)*chosenLength/10e2;
cout<<"Point load:"<<span<<"N"<<endl<<endl;
return span;
}
//***********************************CHECKING BENDING STRESS*********************************************************
void checkBendingStress(beamMember designBeam, double force)
{
cout<<"Bending Stress Check:"<<endl;
double bendingMoment;
double secondMomentofArea;
double designBendingStress;
double actualBendingStress;
bendingMoment=force*chosenLength/8;
cout<<"Maximum bending moment is "<<bendingMoment<<"Nmm"<<endl;
secondMomentofArea=chosenWidth*pow(chosenDepth,3)/12;
designBendingStress=kH*kSYS*kMOD*matrix[0]/gammaM;
actualBendingStress=(bendingMoment*chosenDepth/2)/secondMomentofArea;
cout<<"Maximum permissibile stress:"<<designBendingStress<<"N/mm2"<<endl;
cout<<"The actual stress that the beam is subject to:"<<actualBendingStress<<"N/mm2"<<endl;
if(actualBendingStress<=designBendingStress)
cout<<"Beam bending stress check successful!"<<endl<<endl;
else
cout<<"Beam bending stress check unnsuccessful!"<<endl<<endl;
}
//***********************************CHECKING SHEAR STRESS*********************************************************
void checkShearStress(beamMember designBeam, double force)
{
cout<<"Shear Stress Check:"<<endl;
double designShearingStress;
double actualShearingStress;
designShearingStress=matrix[5]*kMOD*kSYS/gammaM;
actualShearingStress=(1.5*force/2)/(chosenWidth)/(chosenDepth);
cout<<"Maximum permissible shear stress:"<<designShearingStress<<"N/mm2"<<endl;
cout<<"Shear stress that the supports are subjected to:"<<actualShearingStress<<"N/mm2"<<endl;
if(actualShearingStress<=designShearingStress)
cout<<"Beam shear stress check successful!"<<endl<<endl;
else
cout<<"Beam shear stress check unsucessful!"<<endl<<endl;
}
//********************************CHECKING BEARING STRESS***********************************************************
void checkBearingStress(beamMember designBeam, double force)
{
double kc90;
double designBearingStress;
double actualBearingStress;
actualBearingStress=force/2/chosenWidth/chosenBearingLength;
cout<<"Bearing Stress that the beam is subjected to:"<<actualBearingStress<<"N/mm2"<<endl;
designBearingStress=matrix[4]*kMOD*kSYS/gammaM;
cout<<"Maximum permissible bearing stress:"<<designBearingStress<<"N/mm2"<<endl;
kc90=(2.38-chosenBearingLength/250)*(1+chosenDepth/12/chosenBearingLength);
cout<<"Constant, kc90 is "<<kc90<<endl;
cout<<"Factored design bearing stress is "<<kc90*designBearingStress<<endl;
if (actualBearingStress<=designBearingStress)
cout<<"Beam bearing stress check successful!"<<endl<<endl;
else
cout<<"Beam bearing stress check unsuccessful!"<<endl<<endl;
}
//********************************CHECKING LATERAL TORSIONAL STABILITY**************************************************
void checkLateralTorsionalStability(beamMember designBeam, double force)
{
cout<<"Lateral Torsional Stability Check:"<<endl;
double bendingMoment;
double secondMomentofArea;
double designBendingStress;
double actualBendingStress;
bendingMoment=force*chosenLength/8;
cout<<"Maximum bending moment is "<<bendingMoment<<"Nmm"<<endl;
secondMomentofArea=chosenWidth*pow(chosenDepth,3)/12;
designBendingStress=kH*kSYS*kMOD*matrix[0]/gammaM;
actualBendingStress=(bendingMoment*chosenDepth/2)/secondMomentofArea;
cout<<"Maximum permissibile stress:"<<designBendingStress<<"N/mm2"<<endl;
cout<<"The actual stress that the beam is subject to:"<<actualBendingStress<<"N/mm2"<<endl;
if(actualBendingStress<=designBendingStress)
cout<<"Beam Lateral Torsional Stability check successful!"<<endl<<endl;
else
cout<<"Beam Lateral Tosional Stability check unnsuccessful!"<<endl<<endl;
}
//*************************************FUNCTION FOR STRENGTH CLASS DATA FILE**********************************************
void strengthClassData(string classStrength, double serviceClass)
{
string data;
ifstream file;
file.open("strengthclassdata.txt");
file>>data;
while(file&&data!=classStrength)
{
file>>data;
}
for(int i=0;i<=5;i++)
file>>matrix[i];
file.close();
}
//Welcome Message for Program
void welcome()
{
cout<<"The following is Yadhuvamshi Rajamani's program"<<endl
<<"that conducts timber component structural design"<<endl
<<"according to EC5. Specifically, it is a limit state"<<endl
<<"design program that compares design actions with design strengths."<<endl;
}
//******************************BEAM START UP*****************************************************************************
void beamStartUp()
{
beamMember designBeam;
double force;
designBeam.beamDimensionsData();
force=load(designBeam);
checkBendingStress(designBeam,force);
checkShearStress(designBeam,force);
checkBearingStress(designBeam,force);
checkLateralTorsionalStability(designBeam,force);
}
int main()
{
welcome();
char startKey;
cout<<"Please select 1 to start the beam test program or 2 to exit the program, followed by enter!";
cin>>startKey;
cout<<endl;
while(startKey!='2')
{
switch(startKey)
{
case '2':
return 1;
case '1':
beamStartUp();
break;
}
cout<<"Please select 1 to start the beam test program or 2 to exit the program, followed by enter!";
cin>>startKey;
cout<<endl;
}
return 1;
}
};
`
答案 0 :(得分:8)
int main()
函数需要在类定义之外。您将要创建一个类实例并使用它来调用welcome和beamStartUp函数。
答案 1 :(得分:5)