-2
錯誤是: 1> MSVCRTD.LIB(crtexew.obj):錯誤LNK2019:解析外部符號的WinMain @函數引用_ _tmainCRTStartup ,它是給我這個錯誤太 致命錯誤LNK1120 16:1個無法解析的外部我輸入了這段代碼,當我點擊構建時,它給了我這個錯誤?
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
struct student
{
string name;
string department;
double first;
double second;
};
class CS112Section
{
student stu[30];
int numOfStudent;
public:
CS112Section();
~CS112Section();
void printSection();
void insert(student student);
int getNumOfStudent();
string MaxFirstAndSecond();
void Average(double&, double&);
bool isFull();
bool isEmpty();
void AddBounsFirst(int);
};
void main()
{
CS112Section section;
char choice;
bool finish = true;
while (finish != false)
{
cout << "1-Insert Info From .Txt file.\n2-Insert Student Manually.\n3-Show The Number Of Student In The Class.\n";
cout << "4-Print The Content Of The Section.\n5-The Student With The Full Marks First And Second.\n6-Show If";
cout << " The Class Full Or Not.\n7-Print The Average Of The First And The Second.\n8-Do You Want To Add Bouns ?\n";
cout << "9-Exit.";
cin >> choice;
switch (choice)
{
case 1:
case 2:
case 3:
cout << "The Number Of Student In The Section : " << section.getNumOfStudent();
case 4:
section.printSection();
case 5:
section.MaxFirstAndSecond();
case 6:
if (section.isEmpty() == 1)
cout << "The Class Is Empty\n";
else if (section.isFull() == 1)
cout << "The Class Is Full";
case 7:
double avF, avS;
section.Average(avF, avS);
cout << "The Average Of The First Is : " << avF;
cout << "\nThe Average Of The Section Is : " << avS << endl;
case 8:
int x;
cout << "How Many Marks Do You Want To Add ?";
cin >> x;
section.AddBounsFirst(x);
case 9:
finish = false;
}
}
}
CS112Section::CS112Section(){ numOfStudent = 0; }
CS112Section::~CS112Section(){ cout << "Good Luck In Your Final ^_^"; }
void CS112Section::printSection()
{
cout << "the Number Of Student In The Section is : "<<numOfStudent;
cout << "---------------------------------------------";
cout << "Name\tFirst\tSecond\tDepartment\n";
for (int i = 0; i < 30; i++)
cout << stu[i].name << "\t" << stu[i].first << "\t" << stu[i].second << "\t"<<stu[i].department << "\n";
}
void CS112Section::insert(student student)
{
for (int i = 0; i < 30;i++)
if (stu[i].name.empty() == 1 && stu[i].first == stu[i].department.npos&&stu[i].second == stu[i].department.npos&&stu[i].department.empty() == 1)
stu[i] = student;
}
int CS112Section::getNumOfStudent()
{
return numOfStudent;
}
string CS112Section::MaxFirstAndSecond()
{
for (int i = 0; i < 30; i++)
if (stu[i].first == 30 && stu[i].second == 30)
return stu[i].name;
}
void CS112Section::Average(double&avF, double&avS)
{
double sumF = 0, sumS = 0;
for (int i = 0; i < 30; i++)
{
sumF += stu[i].first;
sumS += stu[i].second;
}
for (int i = 0; i < 30; i++)
{
if (stu[i].first == stu[i].department.npos)
sumF = 0;
if (stu[i].second == stu[i].department.npos)
sumS = 0;
}
avF = sumF/30;
avS = sumS/30;
}
bool CS112Section::isFull()
{
if (numOfStudent == 30)
return 1;
return 0;
}
bool CS112Section::isEmpty()
{
if (numOfStudent == 0)
return 1;
return 0;
}
void CS112Section::AddBounsFirst(int Bouns)
{
for (int i = 0; i < 30; i++)
stu[i].first += 1;
}
可能重複的[什麼是未定義的引用/無法解析的外部符號錯誤,以及如何解決它?](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved- external-symbol-error-and-how-do-i-fix) –
在發佈之前請先搜索。 –
@LightnessRacesinOrbit我認爲這個問題比通用的問題更具體一些。 –