如果是在mfc的工程里添加的这两个文件,在student.cpp中添加#include "stdafx.h"然后试一下

解决方案 »

  1.   

    我想你应该在*.h文件中定义一下ostream& operator<<(ostream& out, Student&st)的原型,最好在类中把它声明为友元,这样它就可以访问类的所有成员
      

  2.   

    kerrie的方法我试过不行,请问coolHg ostream& operator<<(ostream& out, Student&st)的原型是什么?
      

  3.   

    在class Student{};中加入friend ostream& operator<<(ostream& out, Student&st);既:
     class Student{
          //...
          friend ostream& operator<<(ostream& out, Student&st);
          }
    就行了。
      

  4.   

    谢谢leer的详尽回复,编译已通过。