草庐IT

Conversion_Constructors

全部标签

c++ - 警告 : overflow in implicit constant conversion

在下面的程序中,第5行确实按预期给出了溢出警告,但令人惊讶的是,第4行在GCC中没有给出任何警告:http://www.ideone.com/U0BXnintmain(){inti=256;charc1=i;//line4charc2=256;//line5return0;}我在想这两行都应该给出overflow警告。还是我缺少什么?我做这个实验的主题是:typedeftypechecking?在那里我说了以下内容(我从答案中删除了,因为当我运行它时,它并没有像我预期的那样显示)://However,you'llgetwarningforthiscase:typedefintT1;ty

c++ - 警告 : deprecated conversion from string constant to 'char*' '

这个问题在这里已经有了答案:关闭11年前。PossibleDuplicate:Howtogetridofdeprecatedconversionfromstringconstantto‘char*’warningsinGCC?我使用库中的以下函数,但我无法更改:HRESULTDynamicTag(char*pDesc,int*constpTag);我使用它如下。我已经创建了实现上述功能的库提供的类的对象。inttag=0;g_pCallback->DynamicTag("MyLogger",&tag);我收到以下警告:warning:deprecatedconversionfromst

c++ - 错误 C2679 : binary '<<' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)

这是我的代码,我该如何解决这个错误?#include"stdafx.h"#includeusingnamespacestd;intmain(){stringtitle="THEWORLDOFPIRATES";cout错误是binary' 最佳答案 你忘了#include使用std::string不包括它的header适用于一些间接导入部分的编译器进入他们的或其他标题,但这不是标准的,不应依赖。此外,当您尝试输出字符串时,它们通常会中断,因为它们仅包含实现的一部分,并且缺少实现operator的部分。.

Java "target type of lambda conversion must be an interface"

我正在尝试在java中使用lambdas和流,但我对它很陌生。当我尝试制作lambda表达式时,我在IntelliJ“目标类型的lambda转换必须是一个接口(interface)”中收到此错误List>callList=prgll.stream().map(p->(()->{returnp.funct();}))我做错了吗? 最佳答案 我怀疑这只是Java的类型推断不够聪明。试试.map(p->(Callable)()->p.funct()) 关于Java"targettypeofla

Java <-> Scala 互操作 : transparent List and Map conversion

我正在学习Scala,并且我有一个要迁移到Scala的Java项目。我想通过一个接一个地重写类并检查新类没有破坏项目来迁移它。这个Java项目使用了很多java.util.List和java.util.Map。在新的Scala类中,我想使用Scala的List和Map来获得好看的Scala代码。问题在于新类(那些在Scala中编写的)不能与现有Java代码无缝集成:Java需要java.util.List,Scala需要自己的scala.List.以下是问题的简化示例。有Main、Logic、Dao类。他们在一行中互相调用:Main->Logic->Dao.publicclassMai

android - Kotlin Realm : Class must declare a public constructor with no arguments if it contains custom constructors

我正在Kotlin中创建一个Realm对象。Realm对象:openclassPurposeModel(var_id:Long?,varpurposeEn:String?,varpurposeAr:String?):RealmObject()当我编译上面的代码时,我得到了这个错误:error:Class"PurposeModel"mustdeclareapublicconstructorwithnoargumentsifitcontainscustomconstructors.我在Kotlin中找不到任何与此相关的问题。我该如何解决这个问题? 最佳答案

Kotlin : Interface Queue does not have constructors

我正在尝试实例化Queue的对象使用下面的代码varqueue:Queue=Queue()但我明白了InterfaceQueuedoesnothaveconstructors不知道发生了什么,我在搜索时发现了link.但我什么都不懂。请帮忙。 最佳答案 Queue是interface.所以你不能实例化一个接口(interface),你必须实现它或者实例化一个实现它的类。例如,你可以做varqueue:Queue=ArrayDeque().ArrayDeque实现Queue. 关于Kotl

java - Spring Data MongoDB : BigInteger to ObjectId conversion

我在使用SpringDataMongoDB进行更新查询时遇到问题。我检索一些对象的_id作为BigInteger值。然后我想进行以下查询:Queryquery=newQuery(Criteria.where("_id").is(id));Updateupdate=newUpdate();update.set("version",version);mongoOperations.updateFirst(query,update,Audit.class);查询部分无法匹配任何文档,因为传递给is()的id值必须以某种方式转换为ObjectId。我找不到任何关于这种转换的文档。将不胜感激任何

php - Symfony2 MoneyType 与除数 : integer conversion leads to wrong database values

我们将所有与货币相关的值都以美分的形式存储在我们的数据库中(ODM但ORM的行为可能相同)。我们使用MoneyType将面向用户的值(12,34€)转换为他们的美分表示(1234c)。typicalfloatprecision这里出现了问题:由于精度不足,许多情况下会产生舍入误差,而这些误差仅在调试时可见。MoneyType会将传入的字符串转换为可能不精确的float("1765"=>1764.9999999998)。一旦你坚持这些值(value)观,事情就会变得糟糕:classPrice{/***@varint*@MongoDB\Field(type="int")**/protect

c++ - 错误 C2679 : binary '>>' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)

请不要与标题混淆,因为它已经有人问过了,但上下文不同VisualC++Compiler(VS2008)中的以下代码没有被编译,而是抛出了这个异常:std::ifstreaminput(fileName);while(input){strings;input>>s;std::cout但是这段代码在cygwing++中编译得很好。有什么想法吗? 最佳答案 您是否包含以下所有标题?我猜你忘了.附带说明:应该是std::cout和std::endl. 关于c++-错误C2679:binary'>