C++里面的std 错误

来源:百度知道 编辑:UC知道 时间:2024/05/17 01:05:57
头文件”Student_info“:
# ifdef GUARD_Student_info
#define GUARD_Student_info

#include <vector>
#include <string>
#include <iostream>

struct Student_info
{
std::string name;
double mid,final;
std::vector<double> homework;

};

std::istream& read_hw (std::istream& in, std::vector<double>& homework);
std::istream& read(std::istream& in, Student_info& s);
bool compare(const Student_info& x, const Student_info& y);
#endif
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#include "Student_info.h"

using std::vector; using std::istream;

// 读取函数
istream& read_hw (istream& in, std::vector<double>& homework)
{
if (in)
{
double x;
while (in>>x)
{ homework.clear();

homework.push_back(x);
}
in.clear();
}

return in;
}
istream& read(i

第一行就错了
应该是#ifndef,不是#ifdef

给分吧 哈哈

除了#ifdef 拼写的问题之外,可能就是命名空间的问题,要在
#include <iostream>下面加上using namespace std;

没在开头写 using namespace std;

#ifdef 拼写错误
#include <iostream>下面加上using namespace std;

也要注意,前面不要空着。有时候会有报错