xmmintrin.h文件报错#ifndef a #define a #include "student.h" #include <iostream> #endif using namespace std; int main(){ student s1; s1.scoretotalcount(100); student s2; s2.scoretotalcount(90); student s3; s3.scoretotalcount(80); student s4; s4.scoretotalcount(95); student s5; s5.scoretotalcount(85); student s6; s6.scoretotalcount(100); cout << "the total score :" << student::sum()<<endl; cout << " the average score of the class:" << student::average() << endl; }#ifndef a #define a #include "student.h" #include <iostream> #endif using namespace std; void student::scoretotalcount(double s){ score = s; count++; total = total + score; cout << "the student" << count << "'s score=" << score << endl << "total score=" << total <<endl<< "th number of student:" << count<<endl; }class student{ double score; static int count; static double total; public: void scoretotalcount(double s); static double sum(){ return total; } static double average(){ return total/count;} }; int student::count = 0; double student::total = 0;
时间: 2024-01-05 08:02:54 浏览: 132
这段代码存在一些问题:
1. `xmmintrin.h`头文件是SSE指令集的头文件,应该与这段代码无关,可能是你在其他地方使用了SSE指令集但没有包含这个头文件。
2. `student`类的定义应该放在`main`函数之前,因为`main`函数中用到了`student`类。
3. `#ifndef a #define a ... #endif` 这段代码似乎没有意义,可以直接删掉。
下面是修改后的代码:
```cpp
#include <iostream>
using namespace std;
class student{
double score;
static int count;
static double total;
public:
void scoretotalcount(double s);
static double sum(){ return total; }
static double average(){ return total/count; }
};
int student::count = 0;
double student::total = 0;
void student::scoretotalcount(double s){
score = s;
count++;
total = total + score;
cout << "the student " << count << "'s score=" << score << endl
<< "total score=" << total <<endl<< "the number of student:" << count<<endl;
}
int main(){
student s1;
s1.scoretotalcount(100);
student s2;
s2.scoretotalcount(90);
student s3;
s3.scoretotalcount(80);
student s4;
s4.scoretotalcount(95);
student s5;
s5.scoretotalcount(85);
student s6;
s6.scoretotalcount(100);
cout << "the total score :" << student::sum()<<endl;
cout << "the average score of the class:" << student::average() << endl;
return 0;
}
```
阅读全文