input/output, operator overloading and dynamic memory management:
string fname, lname;
First, implement the default constructor (which initializes fname and lname to empty strings and IDnum to -1) and the constructor
record(string f,string l,int n)
(which initializes fname to f, etc.).
Next, overload the stream insertion and stream extraction operators . the format for a record is:
( fname lname IDnum )
where there can be arbitrary amounts of white space betwen each field and between the fields and the parentheses (recall that white space is a space, tab, newline, etc.). When reading in a record, you must check to see if the input is properly formatted. If it is not, then you should store -1 in IDnum. The IDnum field is what will be used to specify if a record is invalid. Since the user cannot directly access this field, you must define a member function called valid() that returns boolean type true if it is a valid record and false otherwise.
Finally, define these functions:
int readdb(record *& r, istream &s)
void printdb(record *r,int c,ostream &s)
Function readdb reads records one at a time from istream s using the overloaded stream extraction operator until the end of the input and writes them into an array pointed to by r (the array is to be allocated by readdb). Only valid records are to be read into the array! So e.g. if the following input is given on s:
( Stephen Scott 12345 )
( Leen-Kiat Soh )
( Richard Sincovec 6789 )
Ashok Samal 9914 )
then the first and third records will be stored in the array, but not the second or fourth. Since you don't know a priori how many valid records will be read in, start by pointing r to an array of size 2. After reading 2 records, double its size to 4. If you fill that, then double the size again, and so on. I.e., the size of the final array will be at most twice the number of records. Note that since r is a reference to a pointer to type record, you can point r to new arrays as needed. You should take advantage of this when resizing, which can be done by allocating a new array of twice the size and deleting the old one, or via the C command realloc.
The integer returned by readdb is the number of valid records read, not counting the number of invalid records. It is also not necessarily the final size of the array.
Function printdb takes as input a pointer r to an array of records, an integer c of how many records there are in the array (e.g. the value returned by readdb), and an ostream s to write the records to. Use the overloaded stream insertion operator to write all c records to s.
Bu iş için 17 freelancer ortalamada $39 teklif veriyor
Hi, Please see PMB for more details. Best Regards ... ccpplinux
Hi! I've alredy done a few projects similar to this one (for students :-) ). I'm sure you will be pleased.
I'm a computer scientist from Poland. I've been working as software engineer for the biggest polish software company. The request will be realised quick and professional.
Hi Dear Rehan I am an experienced Developer, Just a new comer to getafreelancer. Not doing this project for the money instead want to have some ranking and some projects with my name. I can do the quality work fo Daha Fazla
Sipmle and easy way of doing the thing is splittng up and analyse in many ways and proceed to towards a better approach. I have an experience on c/C++ so i hope i have crack this to get a better view. Hope i will Daha Fazla
I can do this for 30$. Below there is a header file as specified. There will be a need to add some access methods. If you decided to use an STL collection (here I suggest vector), there would be no need to manipu Daha Fazla
The project is almost done with us Ready delievery