Тип данных о сине? «Члены» cin в C ++? - PullRequest
0 голосов
/ 05 апреля 2020

Я изучаю обработку файлов в C ++. Я узнал о типе данных fstream. Мой вопрос - является ли fstream классом / структурой / объединением? В приведенном ниже коде (только упомянутые соответствующие части) кажется, что getline и ignore являются членами cin? Но getline - это функция: https://www.geeksforgeeks.org/getline-string-c/.

#include <fstream>
#include <iostream>
using namespace std;

    int main () {
       char data[100];

       // open a file in write mode.
       ofstream outfile;
       outfile.open("afile.dat");

       cout << "Writing to the file" << endl;
       cout << "Enter your name: "; 
       cin.getline(data, 100);

       // write inputted data into the file.
       outfile << data << endl;



         cout << "Enter your age: "; 
           cin >> data;
           cin.ignore();

           // again write inputted data into the file.
           outfile << data << endl;

           // close the opened file.
           outfile.close();

Я в замешательстве? Также является ли cin другим именем для класса / структуры / объединения istream? И еще одно название для ostream? Пожалуйста помоги.

...