Writing a class object into a file using fstream and then read it

后端 未结 2 402
执笔经年
执笔经年 2021-01-07 17:38

I want to make a class of a student and take 3 inputs information and make an output of this file. How to this? This is my try:

#include 
usi         


        
2条回答
  •  时光取名叫无心
    2021-01-07 17:57

    You have to overload << and >> operators for ostream and istream

    std::ostream& operator<< (std::ostream& stream, const Student& student)
    std::istream& operator<< (std::istream& stream, Student& student)
    

    make them friend and implement

提交回复
热议问题