Show class | class temp { |
Notes |
Show public | public: |
Notes |
Show def const | temp() {t = 0.0; scale = 'C';} // default constructor |
Notes |
Show 1 arg const | temp(double x) { t = x; scale = 'C'; } // one arg constructor |
Notes |
Show 2 arg const | temp(double x, char sc) { t = x; scale = sc; } // two arg constructor |
Notes |
Show comment | // set the temperature and scale |
Notes |
Show settemp | void setTemp(double v, char sc) { t = v; scale = sc;} |
Notes |
Show getcelsius | double getCelsius(); // get the temperature as Celsius |
Notes |
Show getscale | char getScale() { return scale; } // fetch the scale |
Notes |
Show gettemp | double getTemp() { return t; } // fetch the temp |
Notes |
Show printtemp | void printTemp() { cout << t << " Degrees " << showScale();} |
Notes |
Show private | private: |
Notes |
Show t | double t; // actual temperature reading |
Notes |
Show scale | char scale; // Which scale? Celsius, Kelvin, Fahrenheit, Rankine |
Notes |
Show comment | // private methods can only be called from other methods in the class |
Notes |
Show showscale | char * showScale(); // return the scale in English |
Notes |
Show close brace | } ; |
Notes |