Respuesta :
#include <iostream> Â
#include <iomanip> Â
using namespace std; Â
class temporary Â
{ Â
public: Â
void set(string, double, double); Â
void print(); Â
double manipulate (); Â
void get (string&, double&, double&); Â
void setDescription(string); Â
void setFirst(double); Â
void setSecond(double); Â
string getDescription() const; Â
double getFirst () const; Â
double getSecond () const; Â
temporary(string = "", double = 0.0, double = 0.0); Â
private: Â
string description; Â
double first; Â
double second; Â
}; Â
void temporary::set(string a, double dblA, double dblB) Â
{ Â
description = a; Â
first = dblA; Â
second = dblB; Â
} Â
void temporary::print() Â
{ Â
cout << "\nDescription: " << left << setw(20) << description << endl << Â
" first: " << fixed << setw(10) << setprecision(2) << first << endl << Â
" second: " << fixed << setw(10) << setprecision(2) << second << endl; Â
} Â
double temporary::manipulate() Â
{ Â
return first / 3.0 + second / 4.0; Â
} Â
void temporary::get(string& strDesc, double& dblFirst, double& dblSecond) Â
{ Â
strDesc = description; Â
dblFirst = first; Â
dblSecond = second; Â
} Â
temporary::temporary(string d, double a, double b) : description(d), first(a), second(b) {} Â
void temporary::setFirst(double dblFirst){first = dblFirst;} Â
void temporary::setSecond(double dblSecond){second = dblSecond;} Â
void temporary::setDescription(string desc){description = desc;} Â
string temporary::getDescription() const {return description;} Â
double temporary::getFirst () const{return first;} Â
double temporary::getSecond () const {return second;} Â
int main() Â
{ Â
cout << "temporary a;"; Â
temporary a; Â
a.print(); Â
cout << "a.setFirst(3.0): "; Â
a.setFirst(3.0); Â
a.print(); Â
cout << "a.setSecond(4.5): "; Â
a.setSecond(4.5); Â
a.print(); Â
cout << "a.setDescription(\"Picture Frame\") "; Â
a.setDescription("Picture Frame"); Â
a.print(); Â
cout << "a.print(): "; Â
a.print(); Â
return 0; Â
}