[英]invalid narrowing conversion from (int) to (short) error
I am getting an error with both (short)m_nScreen.我收到两个(短)m_nScreen 的错误。
This is code to create a console window, and whenever I try and run it, I get errors.这是创建控制台 window 的代码,每当我尝试运行它时,都会出错。 The error I get is "invalid narrowing conversion from (int) to (short)"
我得到的错误是“从(int)到(short)的无效缩小转换”
m_rectWindow = { 0, 0, (short)m_nScreenWidth - 1, (short)m_nScreenHeight - 1 };
(short)m_nScreenHeight - 1
narrows m_nScreenHeight
only to widen it again prior to the subtraction with 1, which is an int
- thus an useless narrowing. (short)m_nScreenHeight - 1
缩小m_nScreenHeight
只是为了在减去 1 之前再次加宽它,这是一个int
- 因此是一个无用的缩小。 @MM . @MM 。
Instead, subtract and then narrow the difference.相反,减去然后缩小差异。
// (short)m_nScreenHeight - 1
(short)(m_nScreenHeight - 1)
Same for m_nScreenWidth
. m_nScreenWidth
相同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.