I'm not sure what the problems would be, this is for a class and I need to write the code this way. I am always into easier and better, but I don't think school operates that way.
Here is the derived class:
Code:
#ifndef FIELD_H
#define FIELD_H
#include <string>
#include <iostream>
#include <fstream>
class field : public string
{
public:
// CONSTRUCTORS
// inherited from string class
// MOD MEMBER FUNCTIONS
private:
};
ifstream & operator >> (istream & ifs, field & inputField);
ofstream & operator << (ofstream & ofs, field & outputField);
#include "field.h"
ifstream & operator >> (ifstream & ifs, field & inputField)
{
char temp[150];
getline(ifs, temp, '|');
inputField = string(temp);
return is;
}
ofstream & operator << (ofstream & ofs, field & outputField)
{
while (ofs)
{
ofs << outputField << '|';
}
}
This is what I've got. I don't think I need anything else.
Brian