草庐IT

CONSTANT_NAME

全部标签

c++ - 为什么我得到 "cannot allocate an array of constant size 0"?

这个问题在这里已经有了答案:WhathappensifIdefinea0-sizearrayinC/C++?(8个答案)关闭8年前。我正在为学校做一个扫雷程序,但我的代码中一直出现这个错误cannotallocateanarrayofconstantsize0我不知道为什么会这样;我没有分配大小——我将它设置为0。另一个问题是,我如何通过char读取我的输入char,这样我就可以将它保存在我的数组?正如您在下面看到的,我正在使用输入和输出。我评论了我的输入和输出,这样你们就可以看到我在这个程序中使用了什么。我想通过char读取char,这样我就可以将所有map保存在数组中。我正在使用M

c++ - curl_easy_perform : Couldn't resolve host name

我在使用libcurl时遇到了一些奇怪的问题-它拒绝解析特定的URL,返回错误消息“无法解析主机名”。解决其他主机没有问题。我怀疑原因是失败的URL返回了302重定向,但我已经设置了适当的选项以供遵循。有问题的网址:http://servermods.cursecdn.com/files/922/48/worldedit-bukkit-6.1.3.jar相关代码:CURL*curl;FILE*data;std::stringurl;//...curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,write_callback);curl_easy_set

c++ - 编译器优化 "constant propagation"是什么意思?

摘自ScottMeyers的EffectiveC++:templateclassSquareMatrix:privateSquareMatrixBase{public:SquareMatrix():SquareMatrixBase(n,0),pData(newT[n*n]){this->setDataPtr(pData.get());}...private:boost::scoped_arraypData;};Regardlessofwherethedataisstored,thekeyresultfromabloatpointofviewisthatnowmany—maybeall—

c++ - 海湾合作委员会 4.1.2 : error: integer constant is too large for ‘long’ type

我编译了一段关于散列函数的代码并得到了错误:整数常量对于‘long’类型来说太大了。我用谷歌搜索了一下,它说要添加后缀“ULL”,但我确实有ULL作为后缀。这个后缀只有gcc4.4.1支持,我机器上只有gcc4.1.2,不允许安装新的编译器。有什么方法可以更改代码以解决问题吗?谢谢,-托尼unsignedlonglonghash(stringk){//FNVhashunsignedlonglongx=14695981039346656037ULL;for(unsignedinty=0;y 最佳答案 1099511628211对于(3

c++ - 枚举 "does not name a type' 的问题

g++(Ubuntu/Linaro4.4.4-14ubuntu5)4.4.5我有一个问题,我似乎找到了我得到这个错误的方法。文件statemachine.h#ifndefSTATEMACHINE_H_INCLUDED#defineSTATEMACHINE_H_INCLUDED#include"port.h"enumstate{ST_UNINITIALIZED=0x01,ST_INITIALIZED=0x02,ST_OPENED=0x03,ST_UNBLOCKED=0x04,ST_DISPOSED=0x05};voidstate_machine(eventevt,port_t*port)

c++ - 错误 : ‘i’ does not name a type with auto

这个问题在这里已经有了答案:HowdoIenableC++11ingcc?(4个答案)关闭7年前。我是C++新手,这是我的程序#include#include#include#include#includeintmain(){staticconstdoublearr[]={16.0,2.2,77.5,29.0,24.0};std::vectorvec(arr,arr+sizeof(arr)/sizeof(arr[0]));std::transform(vec.begin(),vec.end(),vec.begin(),bind2nd(std::minus(),3.0));for(aut

C++ : Initializing base class constant static variable with different value in derived class?

我有一个带有常量静态变量a的基类A。我需要类B的实例对静态变量a具有不同的值。这怎么能实现,最好是静态初始化?classA{public:staticconstinta;};constintA::a=1;classB:publicA{//???//Howtoset*a*toavaluespecifictoinstancesofclassB?}; 最佳答案 你不能。所有派生类共享一个静态变量实例。 关于C++:Initializingbaseclassconstantstaticvaria

c++ - 错误 : '...' does not name a type

我有一个工作项目。重新安排一些代码后,我尝试重新编译我的项目,然后奇怪的事情开始发生。查看编译器输出的这段摘录。我正在使用MinGWG++从Windows上的Eclipse进行编译。****BuildofconfigurationDebugforprojectPract2********InternalBuilderisusedforbuild****g++-O0-g3-Wall-c-fmessage-length=0-omove.o..\move.cppInfileincludedfrom..\/game.h:11:0,from..\/piece.h:10,from..\/move.

c++ - 继承 : expected class-name before ‘{’ token

我试图在C++中创建一个异常类,但它不起作用。我已将代码减少到最少,但仍然找不到错误。这是我的头文件:#ifndefLISTEXCEPTION_H#defineLISTEXCEPTION_H//C++standardlibraries#include/*CLASSDEFINITION*/classListException:publicexception{};#endif//LISTEXCEPTION_H这是我得到的错误:error:expectedclass-namebefore‘{’token这是出乎意料的。我该如何解决这个问题? 最佳答案

c++ - std::bool_constant 背后的基本原理

我想知道,引入std::bool_constant背后的基本原理是什么?及其随后用于std::true_type和std::false_type(以及在头文件中定义的比较结构,参见N4389)在C++17中?到目前为止,我只能找到包含以下措辞的论文:http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4334.htmlhttp://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4389.html虽然这两篇论文都提到了“基本原理”——https://issues.isocp