⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 temp.h

📁 数据结构C++语言描术—清华大学出版的
💻 H
字号:
#ifndef TEMPERATURE_CLASS
#define TEMPERATURE_CLASS

class Temperature
{
    private:
        // data holding current high and low readings for the day   
        float highTemp, lowTemp;
    public:
        // constructor. no default parameters
        Temperature (float h, float l);
        
        // methods to retrieve and modify private data
        void UpdateTemp (float temp);                   
        float GetHighTemp (void) const;             
        float GetLowTemp (void) const;          
};

// constructor. asssign user data h to highTemp and l to lowTemp. 
Temperature::Temperature(float h, float l) : highTemp(h), lowTemp(l)
{}
    
// update current temperature readings if temp produces new high or low
void Temperature::UpdateTemp (float temp)
{
    if (temp > highTemp)
        highTemp = temp;
    else if (temp < lowTemp)
        lowTemp = temp;
}

// return the high
float Temperature::GetHighTemp(void) const
{
    return highTemp;
}

// return the low
float Temperature::GetLowTemp(void) const
{
        return lowTemp;
}

#endif  // TEMPEATURE_CLASS

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -