簡體   English   中英

從unsigned int轉換為uint16_t的轉換錯誤

[英]Casting error converting from unsigned int to uint16_t

為什么會出現此錯誤

1> c:\\ users \\ g \\ documents \\ Visual Studio 2012 \\ projects \\ tlvdemo \\ tlvdemo \\ tlvobject.cpp(50):錯誤C2440:'type cast':無法從'unsigned int(__thiscall std :: basic_string <_Elem ,_Traits,_Alloc> :: *)(void)throw()const'到'uint16_t'

以及如何解決?

uint16_t tagLen = (uint16_t)m_tagName.length; //m_tagName is string type

問題在於您調用length方法的方式。

您必須使用m_tagName.length();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM