int GetMonth( ) const throw( );后面的throw( )什么意思?

异常规范(Exception Specifications)
throw后面规定了该函数允许抛出什么类型的异常,空表示不抛出任何异常。这样写函数声明后,你在实现GetMonth时就不能有任何throw语句。
如果写为 int GetMonth( ) const throw(string);

函数实现时可以抛出string对象,其它类型的对象不允许。


嗯,其实应该就是为了在异常处理的时候不引发新的异常,导致死循环。。 奋斗cj 注~
``` <div class="weather-item"> <h1>东营市实时天气:</h1> <img src="/images/icon/QWeather-Icons-1.6.0/icons/300.svg" referrerPolicy="no-referrer" id="weatherIcon" alt="QWeather Icons" width=" 100" height="100"> <!-- <img referrerPolicy="no-referrer" id="weatherIcon"> --> <p class="temp"><span id="temp"></span>℃</p> <p class="wind"><span id="text"></span> <span id="wind"></span></p> <p class="time"><span id="obsTime"></span></p> </div> <script> const apiKey = 'c6000e846a7241e693f05c81e18042a6'; const cityId = '101121201'; async function getWeather() { try { const response = await fetch( `https://devapi.qweather.com/v7/weather/now?location=${cityId}&key=${apiKey}` ); if (!response.ok) throw new Error('请求失败'); const data = await response.json(); console.log('API响应数据:', data); // 数据 document.getElementById('obsTime').textContent = formatObsTime(data.now.obsTime); document.getElementById('temp').textContent = data.now.temp; document.getElementById('text').textContent = data.now.text; document.getElementById('wind').textContent = `${data.now.windDir} ${data.now.windScale}级` function formatObsTime(isoString) { const date = new Date(isoString); return `${date.getFullYear()}年${(date.getMonth()+1).toString().padStart(2,'0')}月${date.getDate().toString().padStart(2,'0')}日 `; } // 图标 const iconCode = String(data.now.icon).padStart(3, '0'); const iconUrl = `https://qweather.com/weather/icons/${iconCode}.png`; // 刷新图片缓存 document.getElementById('weatherIcon').src = iconUrl + '?t=' + Date.now(); } catch (error) { console.error('获取天气失败:', error); // 错误提示 } } getWeather(); </script>```<img src="/images/icon/QWeather-Icons-1.6.0/icons/300.svg" referrerPolicy="no-referrer" id="weatherIcon" alt="QWeather Icons" width=" 100" height="100">如何根据天气返回的值不同,动态更新天气图标,图标都存在images/icon/QWeather-Icons-1.6.0/icons里,需要动态更改300或301......
最新发布
03-23
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值