草庐IT

identifier-required

全部标签

c++ - 在 C 枚举错误中使用单词 "SING"到 "expected an identifier"

在头文件中我有以下枚举:namespaceOBJ_VERBS{enum{zero,CUDDLE,EMBRACE,FLIP,GROPE,HUG,KISS,LICK,NUDGE,PAT,PINCH,POKE,PULL,RUB,SHAKE,SQUEEZE,TAP,TUG,TURN,WAVE,PEER,PET,CLENCH,CURSE,NUZZLE,SNAP,STROKE,TWIRL,LEAN,GRIP,SMELL,GRUNT,SQUEAL,SCOLD,GAZE,WIND,SPIT,SPIN,DANCE,SING,zTOTAL};constint_MAX_=int(OBJ_VERBS::zTO

c++ - 写 "::namespace::identifier"和 "namespace::identifier"有什么区别?

我在代码中看到了这两种方法。你能解释一下这两者有什么区别吗?正如我认为它与C++完成命名空间查找的方式有关,您能否也提供一些相关信息,或者提供一个好的文档的链接?谢谢。 最佳答案 示例:#includenamespacex{constinti=1;}namespacey{namespacex{constinti=2;}voidfunc(){std::printf("x::i=%d\n",x::i);std::printf("::x::i=%d\n",::x::i);}}intmain(){y::func();return0;}输出:

c++ - 继续获取 "error: use of undeclared identifier ' cout' 和错误 : reference to overloaded function could not be resolved

我正在编写一个使用许多不同函数的排序程序,你们都可以从我的声明。但是,当我尝试编译和运行我的程序时,我不断遇到这些相同的错误它们如下:error:useofundeclaredidentifier'cout';didyoumean'count'?couterror:referencetooverloadedfunctioncouldnotberesolved;didyoumeantocallit?couterror:useofundeclaredidentifier'endl';didyoumean'end'?cout我不太确定为什么会出现这些错误....我想我已经包含了我需要的一切为

C++ 相关名称 : Is this typename required?

在a.hpp中我定义了:#includenamespaceBoard{templatestructGroupNode{usingPointType=std::pair;//...};}然后,在b.cpp中我定义了:#include"a.hpp"namespaceBoard{templatestructNodeList{usingStdList=std::list>;}}//andthenuseNodeListnl;上面的代码可以在没有任何警告的情况下在gcc-6和clang-3.9上编译。但是,Clion2016.3提示cannotresolvevariableGroupNodeinb

c++ - CONCEPT_REQUIRES_ ranges-v3 中的实现

试图学习如何使用EricNiebler的ranges-v3库,并阅读源代码,我看到了宏定义:#defineCONCEPT_PP_CAT_(X,Y)X##Y#defineCONCEPT_PP_CAT(X,Y)CONCEPT_PP_CAT_(X,Y)///\addtogroupgroup-concepts///@{#defineCONCEPT_REQUIRES_(...)\intCONCEPT_PP_CAT(_concept_requires_,__LINE__)=42,\typenamestd::enable_if::type=0\/**/因此,简而言之,模板定义如下:template(

c++ - 在 C++ 中 : Is const reference means "read-only view of" or it requires immutability of object being referenced?

问题可以通过示例表述如下:这段代码有效吗?inta=1;constint&ca=a;++a;//对于MSVC和MinGW,上面的代码片段按预期工作:如果我查询ca后记,它返回2(即它被非常量引用更改)。但问题是:如何从标准的角度考虑这种情况?我们是否可以更改对象,我们有const引用(或者例如,我们必须将ca定义为constvolatile引用以使代码片段正确)?所以,如果上面的片段是正确的,那么这意味着,const引用并不能保证引用的对象是常量。它只是禁止我们通过给定的引用来更改它,即建立引用对象的“只读”View。这是正确的吗?编辑:感谢所有回答我问题的人。答案说明了事情,这对我来

我不明白的 C++ 错误 : syntax missing ';' before identifier

classDialogue{public:intid;inttrigger;Questiondescendants[5];//Maxquestionsperdialoguestringtext;};classQuestion{public:intid;intdescendant;intancestor;stringtext;};当我尝试构建它时,它说问题后代位出现以下错误?Error1errorC2146:syntaxerror:missing';'beforeidentifier'descendants'c:\users**\documents\visualstudio2012\pr

c++ - 错误 C3861 : '_tcsdup' : identifier not found

这是我第一次,我想使用Windows进行并行处理CreateProcess功能。基于MSDN上的示例,我创建了一个LPTSTR"(non-const)TCHARstring"commandline这样的争论LPTSTRszCmdline[]=_tcsdup(TEXT("\C:\\MyProgram_linux_1.1\\MyProgram.exe"));LPTSTR和其他charandstringtypesarediscussedhere命令行参数传递给CreateProcess像这样if(!CreateProcess(NULL,szCmdline,/*...*/))cout并且存在这

c++ - 编译为 C++ 但不是 C(错误 : lvalue required as unary '&' operand)

当我使用C++而不是C时,这一行编译:gmtime(&(*(time_t*)alloca(sizeof(time_t))=time(NULL)));//用alloca创建一个左值我对这种差异感到惊讶。甚至没有针对C++的警告。当我指定gcc-xc时,消息是:playground.cpp:25:8:error:lvaluerequiredasunary'&'operandgmtime(&(*(time_t*)alloca(sizeof(time_t))=time(NULL)));^这里的&不就是一个address-of操作符吗?为什么在C和C++中不同?虽然我可以在C中使用复合字面量,但

c++ - 是否允许在 requires 表达式中为 return-type-requirement 指定类型?

看看这个简单的概念示例:templaterequiresrequires(Tt){{t+t}->bool;}voidfn(){}intmain(){fn();}这里,我使用bool作为return-type-requirement的type-constraint。当前稿says:type-constraint:nested-name-specifieroptconcept-namenested-name-specifieroptconcept-name所以type-constraint必须是一个concept-name。bool(或任何类型)是否允许作为概念名称?如果是,那是什么意思,