#include "widget.h" Widget::Widget(string objectID, string value) { setID(objectID); setValue(value); cout << "Construction: "; insert(cout); cout << endl; } Widget::Widget(const Widget &source) { string id = "copyOf" + source.getID(); string value = source.getValue(); setID(id); setValue(value); cout << "Copy construction: "; insert(cout); cout << endl; } string Widget::getID() const { return thisObjectID; } string Widget::getValue() const { return thisValue; } void Widget::setID(string s) { thisObjectID = s; } void Widget::setValue(string s) { thisValue = s; } void Widget::insert(ostream &sout) const { sout << "(" << getID() << " - " << getValue() << ")"; } void Widget::extract(istream &sin) { string newValue; sin >> newValue; setValue(newValue); } Widget& Widget::operator=(const Widget &source) { cout << "Assignment: "; insert(cout); string newValue = source.getValue(); setValue(newValue); cout << " now has value "; insert(cout); cout << endl; return *this; } ostream& operator<<(ostream &sout, const Widget &object) { object.insert(sout); return sout; } istream& operator>>(istream &sin, Widget &object) { object.extract(sin); return sin; }