大神帮我看看
--------------------Configuration: StudentsVsCPlusPlus - Win32 Debug--------------------Compiling...
StudentsVsCPlusPlus.cpp
C:\Documents and Settings\Administrator\桌面\StudentsVsCPlusPlus\StudentsVsCPlusPlus.cpp(65) : error C2593: 'operator >>' is ambiguous
C:\Documents and Settings\Administrator\桌面\StudentsVsCPlusPlus\StudentsVsCPlusPlus.cpp(66) : error C2593: 'operator <<' is ambiguous
C:\Documents and Settings\Administrator\桌面\StudentsVsCPlusPlus\StudentsVsCPlusPlus.cpp(73) : error C2593: 'operator >>' is ambiguous
C:\Documents and Settings\Administrator\桌面\StudentsVsCPlusPlus\StudentsVsCPlusPlus.cpp(76) : error C2593: 'operator <<' is ambiguous
C:\Documents and Settings\Administrator\桌面\StudentsVsCPlusPlus\StudentsVsCPlusPlus.cpp(77) : error C2593: 'operator >>' is ambiguous
Error executing cl.exe.
StudentsVsCPlusPlus.obj - 5 error(s), 0 warning(s)
这五个错误时怎么回事 啊,在vc6里面出现的错误 ,在vs2010中无误,这个错误怎么改呢,下面是相关的一些代码,
#include "stdafx.h"
#include <iostream>
#include "Student.h"
#include"Friend.h"
#include"Teacher.h"
#include <fstream>
#include <string>
#include <iomanip>
#include <cstdlib>
ostream & operator<<(ostream &out,Student &s)
{
out<<s.name<<""<<s.num<<""<<s.nAge<<""
<<s.addr<<'\n';
return out;
}
istream & operator>>(istream &in,Student &s)
{
in>>s.name>>s.num>>s.nAge>>s.addr;
return in;
}
extern _CRTIMP istream MyMethod()
{
return cin;
}
int main(int argc, char* argv[])
{
ofstream ofile;
ifstream ifile;
ofile.open("d:s.txt");
Student s;
for (int i=1;i<=3;i++)
{
cout<<"请输入第"<<i<<"个学生的姓名 学号 年龄 住址"<<endl;
MyMethod()>>s; //调用>>运算符重载函数,输入学生信息
ofile<<s; //调用<<运算符重载函数,将学生信息写入到文件中
}
ofile.close();
cout<<"\n读出文件内容"<<endl;
ifile.open("d:\\s.txt");
ifile>>s;
while(!ifile.eof())
{
cout<<s;
ifile>>s;
}
ifile.close();
}
student类中相关代码
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <string>
#include <iostream>
#include"Person.h"
using namespace std;
class Student : public Person
{
public:
char name[10];
int num;
char addr[15];
friend ostream & operator<<(ostream &out,Student &s);
friend istream & operator>>(istream &in,Student &s);
string strNO;
string strName;
int nAge;
string strGender;
string strInterest;
int nStudyWill;//0~100表示学习意愿
private:
int nHeight;
int nWeight;
public:
string GetTask();
friend void Display(Student &stu)
{
cout << "开始输出个人的公开信息:" << endl;
stu.PrintInfo();
cout << "开始输出个人隐私信息:"<<endl;
cout << "身高:" << stu.nHeight << endl;
cout << "体重:" << stu.nWeight << endl;
}
void SetPersonalInfo(int iHeight,int iWeight);
void PrintInfo();
Student();
Student(string sNO,string sName,int iAge,string sGender,
string sInterest,int iStudyWill);
virtual ~Student();
friend class Friend;
};
与错误相关的代码就是这些了 ,大神些帮帮我吧,在vc6中怎么改 ?vs2010中可以正常编译。谢谢