本篇文章為大家展示了為什么uint8_t 類型變量無利用c++進(jìn)行打印,內(nèi)容簡(jiǎn)明扼要并且容易理解,絕對(duì)能使你眼前一亮,通過這篇文章的詳細(xì)介紹希望你能有所收獲。
創(chuàng)新互聯(lián)是專業(yè)的古縣網(wǎng)站建設(shè)公司,古縣接單;提供網(wǎng)站設(shè)計(jì)制作、成都網(wǎng)站設(shè)計(jì),網(wǎng)頁設(shè)計(jì),網(wǎng)站設(shè)計(jì),建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行古縣網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴(kuò)展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團(tuán)隊(duì),希望更多企業(yè)前來合作!將uint8_t 轉(zhuǎn)化為unsigned 類型
使用一元運(yùn)算符+(和- 運(yùn)算符對(duì)應(yīng))
測(cè)試代碼如下
#include#include #include int main() { std::uint8_t uint8_num = 10; std::cout << "uint8_t num is " << uint8_num << std::endl; //無法打印 std::cout << "after cast to unsigned, uint8_t num is " << unsigned(uint8_num) << std::endl; //能正常打印 std::cout << "with a unary + operator, uint8_t num is " << +uint8_num << std::endl; //能正常打印 std::cout << "type of '+uint8_num' is " << typeid(+uint8_num).name() << std::endl; return 0; }