求大佬帮我看下这个c++程序的错误。
___________________your_student.hclassmy_student;classyour_student{private:intid;ints...
___________________your_student.h
class my_student;
class your_student
{
private:
int id;
int score;
public
void jisuan(my_student &b);
friend class my_student;
};
__________________your_student.cpp
#include "my_student.h"
#include "your_student.h"
class my_student;
class your_student;
void your_student::jisuan(my_student &b)
{
b.id = 18;
b.score = 22;
cout << b.id << " " << b.score << endl;
}
___________________my_student.h
class your_student;
class my_student
{
private:
int id;
int score;
public:
friend class your_student;
};
___________________my_student.cpp
#include "your_student.h"
#include "my_student.h"
class my_student;
class your_student;
___________________main.cpp
#include<iostream>
#include <your_student.h>
#include <my_student.h>
using namespace std;
class my_student;
class your_student;
int main()
{
return 0;
} 展开
class my_student;
class your_student
{
private:
int id;
int score;
public
void jisuan(my_student &b);
friend class my_student;
};
__________________your_student.cpp
#include "my_student.h"
#include "your_student.h"
class my_student;
class your_student;
void your_student::jisuan(my_student &b)
{
b.id = 18;
b.score = 22;
cout << b.id << " " << b.score << endl;
}
___________________my_student.h
class your_student;
class my_student
{
private:
int id;
int score;
public:
friend class your_student;
};
___________________my_student.cpp
#include "your_student.h"
#include "my_student.h"
class my_student;
class your_student;
___________________main.cpp
#include<iostream>
#include <your_student.h>
#include <my_student.h>
using namespace std;
class my_student;
class your_student;
int main()
{
return 0;
} 展开
展开全部
程序有以下错误:
your_student.h中,“public”标志符后缺少“:”,需要加上。
your_student.cpp中,“cin”和“cout”是在“iostream”头中定义的,需要引入,即添加“#include <iostream>”语句。要想直接使用“cin”和“cout”,需要加上“using namespace std”语句。
main.cpp中,include自定义头文件时,需要用双引号,用尖括号只会查找系统目录,会找不到自定义的头文件。改成 #include "your_student.h" 和 #include "my_student.h"。
这些错误大部分属于语法错误,在编译阶段都会提示出来。注意看编译器提示的错误信息,排查起来并不困难。
追问
谢谢
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询