Hmm... perhaps you want to overload the behaviour of << ? I'd say create a base class <strong>CFileWrite</strong> which implements member functions which print to a file and to the screen.
Then perhaps for each sensor object you overload the << operator to your needs.
class CFileWrite {
protected:
void printToFileAndScreen(string data);
};
class CSensor : public CFileWrite {
friend ostream& operator<<(ostream &s, CSensor &obj);
};
Your overloaded << can print out any necessary information from the class. Additionally, you could apply this to CFileWrite so that each individual sensor class doesn't have to overload the << if they don't want to.
John A
Vampirical Lurker
7,630 posts since Apr 2006
Reputation Points: 2,240
Solved Threads: 339