PDA

View Full Version : تصحیح برنامه



mahdi20072008
سه شنبه 03 آذر 1388, 18:18 عصر
سلام دوستان
اگه کسی هست که به برنامه نویسی شی گرا آشنایی داره این برنامه منو اصلاح کنه.
ممنون:چشمک:

این هم متن برنامه

//person.h
class person
{
public:
//fields
char LastName[11];
char FirstName[11];
char address[16];
char city[16];
char state[3];
char ZipCode[10];
//operations
person();
static int lnitBuffer (DelimFieldBuffer &);
static int lnitBuffer (LengthFieldBuffer &);
static int lnitBuffer (FixedFieldBuffer &);
void clear();
int Unpack(IOBuffer &);
int pack(IOBuffer &)const;
void print (ostream &,char *label=0)const;
}
//writestr.cpp
#include <fstream.h>
#include <string.h>
#include "readper.cpp"
ostream & operator <<(ostream & stream,person & p)
{//insert field into file
stream<< p.LastName <<p.FirstName <<p.address <<p.city <<p.state <<p.ZipCode;
return stream;
}
int main()
{
char filename[20];
person p;
cout<<"Enter the name of the file:"<<flush;
cin.getline(filename,19);
ofstream stream(filename,ios::out);
if (stream.file())
{
cout<<"File open FAILED!\i"<<endl;
return 0;
}
while(1)
{
cin>>p;//read fields of person
if (strlen(p.LastName)==0)break;
//write person to output stream
stream << p;//write fields of person
}
return 1;
}