Добавил:
korayakov
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Лабы / C++.Ашарина / !Сделанные / Lab7 / Var12 / File
.cpp#include"file.h"
#include<string.h>
file::file(char *fname, char *mode)
{
name=new char[strlen(fname)+1];
strcpy(name,fname);
cont=fopen(name,mode);
}
file::~file()
{
fclose(cont);
delete name;
}
file *file::operator +(file &f)
{
char c;
fseek(cont,0,2);
fseek(f.cont,0,0);
c=getc(f.cont);
while (!feof(f.cont))
{
putc(c,cont);
c=getc(f.cont);
}
return this;
}
file* file::operator =(file &f)
{
char c;
if (f.cont==NULL)
return NULL;
else
{
fclose(cont);
cont=fopen(name,"w");
fseek(f.cont,0,0);
c=getc(f.cont);
while (!feof(f.cont))
{
putc(c,cont);
c=getc(f.cont);
}
}
return this;
}