Перегрузить оператор >> для реализации множество копирования файлов. A >> B >> C

Можете посмотреть на саму программу,и сказать где находится ошибка

Перегрузить оператор >> для реализации множество копирования файлов. A >> B >> C.

main.cpp

#include "mystring.h"

int main()
{
    ofstream fout;
    ifstream fin;

    Mystring a,b,c,d;
    cout<<"Enter numbers A:";
    cin>>a;
    cout<<"\nEnter numbers B:";
    cin>>b;
    cout<<"\nEnter numbers C:";
    cin>>c;
    cout<<"Console output\n";
    cout<<a<<b<<c<<"\n";
    fout.open("operator.txt", std::ofstream::out);
    fout << a;
    fout << b;
    fout << c;
    cout<<"File output\n";
    cout<<a<<b<<c<<"\n";
    fout.close();

    return 0;
}

mystring.cpp

#include "mystring.h"
#define MAX_STR_LEN 10
Mystring::Mystring() {
     str = new char[MAX_STR_LEN+1]{};
}


ostream& operator<< (ostream &out, const Mystring &obj)
{

    out << "" << obj.str  << " ";

    return out;
}

istream& operator>> (istream &in, Mystring &obj)
{

    in >> obj.str;


    return in;
}
ofstream& operator<< (ofstream &out, const Mystring &obj)
{

    out << "" << obj.str << " ";

    return out;
}

ifstream& operator>> (ifstream &in, Mystring &obj)
{

    in >> obj.str;


    return in;
}

mystring.h

   #ifndef MYSTRING_H
#define MYSTRING_H

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

class Mystring
{


public:
    char *str;
    Mystring();

    friend ostream& operator<< (ostream &out, const Mystring &number);
    friend istream& operator>> (istream &in, Mystring &number);

};

#endi

f // MYSTRING_H


Ответы (0 шт):