Hello everyone.
I am trying to write a simple program that shows me at a glance what services were given to my clients over the last year. I am trying to teach myself C++ as I go. The problem I am having is reading a text file into a class. My class is written in a header file.
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
class customers
{
public:
customers(){};
~customers(){};
string getf_name(){return f_name;}
string getl_name(){return l_name;}
int getJan(){return Jan;}
int getFeb(){return Feb;}
int getMar(){return Mar;}
int getApr(){return Apr;}
int getMay(){return May;}
int getJun(){return Jun;}
int getJul(){return Jul;}
int getAug(){return Aug;}
int getSep(){return Sep;}
int getOct(){return Oct;}
int getNov(){return Nov;}
int getDec(){return Dec;}
string getnotes(){return notes;}
protected:
string f_name;
string l_name;
int Jan;
int Feb;
int Mar;
int Apr;
int May;
int Jun;
int Jul;
int Aug;
int Sep;
int Oct;
int Nov;
int Dec;
string notes;
};
class Monthly : public customers
{
public:
Monthly(string _f_name="",string _l_name="",int _Jan=0,int _Feb=0,int _Mar=0,int _Apr=0,int _May=0,int _Jul=0,int _Jun=0,int _Aug=0,int _Sep=0,int _Oct=0,int _Nov=0,int _Dec=0,string _notes)
{f_name=_f_name;l_name=_l_name;Jan=_Jan;Feb=_Feb;Mar=_Mar;Apr=_Apr;May=_May;Jun=_Jun;Jul=_Jul;Aug=_Aug;Sep=_Sep,Oct=_Oct,Nov=_Nov;Dec=_Dec;notes=_notes;};
~Monthly(){};
};
A short version of my text file looks like this:
My list is about 300 names... So I only posted a short list to give you an idea.
"Earl","Booth",2,2,23,2,4,2,2,23,2,2,4,12,""
"Carol","Hudson",2,2,234,2,2,234,2,2,234,2,2,234,"3 months behind as of 11/10"
"Bob","Ramis",2,2,2,2,2,2,2,2,2,2,2,2,"2/10 - Evidence of old termite tube located upon inspection. Bob insists it is a new tube. Destroyed top half of tube and marked the level. Will re-inspect each month to see if tube reforms. No other evidence found. House is under contract. All repairs made look solid."
Now, how can I read this text file, put it in the class so I can access it? I have tried to read the file in from the tutorials with little success, a word here, a sentence there... and when I tried to put it into the class... horrendous results. I can have my secretery reformat the text file any way needed. From what I've read, I think the class is so so.. ok...
Eventually, I want to be able to update the files monthly, and save a year to year file, but I'd be happy to be able to tell what we've done for the people at this point. Any help would be appreciated.
Thank you in advance