Записать объект класса в файл с помощью fstream, а затем прочитать его

Я хочу сделать урок для ученика, взять 3 входные данные и сделать вывод из этого файла. Как к этому? Это моя попытка:

#include <iostream>
using namespace std;
class Student{
  private:
    char name[50];
    char id[50];
    int age;
  public:
    void getdata()
    {
        //take name as input
        //take id as input
        //take age as input
    }
    void showdata()
    {
         //display stored file
    }
 }

int main()
{
    Student s1;
    ofstream s1("student.txt");      //i want to store that 's1' object
    //anything else
    return 0;
}

Ответы на вопрос(2)

Ваш ответ на вопрос