草庐IT

explicit-conversion

全部标签

c++ - 警告 C4244 : 'argument' : conversion from 'time_t' to 'unsigned int' , 可能丢失数据 -- C++

我制作了一个简单的程序,允许用户选择一些骰子然后猜测结果......我之前发布了这段代码,但有错误的问题,所以它被删除了......现在我不能有任何错误甚至此代码上的警告,但由于某种原因,此警告不断弹出,我不知道如何修复它...“警告C4244:'argument':从'time_t'转换为'unsignedint',可能丢失数据”#include#include#include#includeusingnamespacestd;intchoice,dice,random;intmain(){stringdecision;srand(time(NULL));while(decision

c++ - Visual Studio 2013 'explicit' 关键字错误?

考虑以下程序:#includeclassA{public:A(){std::coutvoidf(Ta=A()){}intmain(void){f();return0;}VisualStudio2013编译此代码并运行,并输出A()operatorint()A(42)这是编译器错误吗?看起来VS编译器在这种情况下没有注意“显式”关键字。据我了解,VS2013错误地将运算符int()与A(int)结合使用来排序“copy-construct”A作为f的默认参数。都加Aa;Aa1(a);到main并将f声明为voidf(Aa=A()){}不编译,VS提示A(A&)被删除,这似乎是正确的行为。

c++ - Visual Studio 2013 'explicit' 关键字错误?

考虑以下程序:#includeclassA{public:A(){std::coutvoidf(Ta=A()){}intmain(void){f();return0;}VisualStudio2013编译此代码并运行,并输出A()operatorint()A(42)这是编译器错误吗?看起来VS编译器在这种情况下没有注意“显式”关键字。据我了解,VS2013错误地将运算符int()与A(int)结合使用来排序“copy-construct”A作为f的默认参数。都加Aa;Aa1(a);到main并将f声明为voidf(Aa=A()){}不编译,VS提示A(A&)被删除,这似乎是正确的行为。

C++ 警告 : deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]

我正在使用gnuplot在C++中绘制图形。该图正在按预期绘制,但在编译期间出现警告。警告是什么意思?warning:deprecatedconversionfromstringconstantto‘char*’[-Wwrite-strings]这是我正在使用的功能:voidplotgraph(doublexvals[],doubleyvals[],intNUM_POINTS){char*commandsForGnuplot[]={"settitle\"ProbabilityGraph\"","plot'data.temp'withlines"};FILE*temp=fopen("da

C++ 警告 : deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]

我正在使用gnuplot在C++中绘制图形。该图正在按预期绘制,但在编译期间出现警告。警告是什么意思?warning:deprecatedconversionfromstringconstantto‘char*’[-Wwrite-strings]这是我正在使用的功能:voidplotgraph(doublexvals[],doubleyvals[],intNUM_POINTS){char*commandsForGnuplot[]={"settitle\"ProbabilityGraph\"","plot'data.temp'withlines"};FILE*temp=fopen("da

python - future 警告 : Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated

更新我的Numpy和Tensorflow后,我收到了这些警告。我已经尝试过these,但没有任何效果,每一个建议都将不胜感激。FutureWarning:Conversionofthesecondargumentofissubdtypefrom`float`to`np.floating`isdeprecated.Infuture,itwillbetreatedas`np.float64==np.dtype(float).type`.from._convimportregister_convertersas_register_converters2018-01-1917:11:38.69

python - future 警告 : Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated

更新我的Numpy和Tensorflow后,我收到了这些警告。我已经尝试过these,但没有任何效果,每一个建议都将不胜感激。FutureWarning:Conversionofthesecondargumentofissubdtypefrom`float`to`np.floating`isdeprecated.Infuture,itwillbetreatedas`np.float64==np.dtype(float).type`.from._convimportregister_convertersas_register_converters2018-01-1917:11:38.69

warning: #68-D: integer conversion resulted in a change of sign

在学习STM32的时候遇到一个很奇怪的warning乍一看这就是一个很常见的定义变量且赋值的语句,感觉没有什么毛病。但是仔细看这是一个u8类型的变量,并且编译显示整数转换导致了符号的改变。所以问题应该就是变量的类型混淆所造成的。咱们深入keil内部去看看u8的本质是什么:这样就很明显了,u8-->uint8_t-->unsignedchar;所以编译出现整数转换导致了符号的改变的问题也就能理解了,因为这个变量类型按理来说是没有符号的,所以如果想要解决这个问题,只用把本例中result的初值改为正数就好。那为什么同样的东西,设计者要采用这么多名字呢?其实一方面就是为了程序员在编写代码的时候能最大

java - "array initializer needs an explicit target-type"- 为什么?

关注JEP286:Local-VariableTypeInference说明我想知道,引入这种限制的原因是什么,例如:Main.java:199:error:cannotinfertypeforlocalvariablekvark={1,2};^(arrayinitializerneedsanexplicittarget-type)所以对我来说逻辑上应该是:vark={1,2};//Infersint[]varl={1,2L,3};//Inferslong[]因为Java编译器可以正确推断出数组的类型:voiddecide(){arr(1,2,3);//callvoidarr(int.

java - "array initializer needs an explicit target-type"- 为什么?

关注JEP286:Local-VariableTypeInference说明我想知道,引入这种限制的原因是什么,例如:Main.java:199:error:cannotinfertypeforlocalvariablekvark={1,2};^(arrayinitializerneedsanexplicittarget-type)所以对我来说逻辑上应该是:vark={1,2};//Infersint[]varl={1,2L,3};//Inferslong[]因为Java编译器可以正确推断出数组的类型:voiddecide(){arr(1,2,3);//callvoidarr(int.