草庐IT

Declared

全部标签

c++ - 使用 bind2nd() : "member function already defined or declared" instead of "reference to reference" 的奇怪编译器错误

我最近花了很多时间来理解在这段代码中调用func()时的错误消息:intmain(){vector>v;doublesum=0;for_each(v.begin(),v.end(),bind2nd(ptr_fun(func),&sum));return0;}当func()像这样声明时,代码编译正常:voidfunc(vectorv,double*sum){}当我使用这个声明(为了提高效率)时,我得到了一个编译器错误:voidfunc(constvector&v,double*sum){}我期望看到的错误类似于reference-to-reference错误,因为binder2nd的op

c++ - 错误 : uint64_t was not declared in this scope when compiling C++ program

我正在尝试一个简单的程序来打印steady_clock的时间戳值,如下所示:#include#includeusingnamespacestd;intmain(){cout(steady_clock::now().time_since_epoch()).count();cout但是每当我像这样编译时g++-oabcabc.cpp,我总是会遇到错误:Infileincludedfrom/usr/include/c++/4.6/chrono:35:0,fromabc.cpp:2:/usr/include/c++/4.6/bits/c++0x_warning.h:32:2:error:#er

c++ - 错误 C2248 : 'std::basic_ios<_Elem,_Traits>::basic_ios' : cannot access private member declared in class 'std::basic_ios<_Elem,_Traits>'

收到此错误,我很确定它在operatorvoidCRational::print()const{print(cout);}voidCRational::print(ostream&sout)const{if(m_denominator==1)cout 最佳答案 您需要通过引用而不是值返回ostream。它试图调用构造函数。也可以传递'a'作为引用:ostream&operator我还注意到打印方法可能是错误的。它有sout作为流的名称传递,但随后直接使用cout实现。应该是voidCRational::print(ostream&s

C++ : Why cant static functions be declared as const or volatile or const volatile

这个问题在这里已经有了答案:关闭10年前。PossibleDuplicate:C++-Whystaticmemberfunctioncan’tbecreatedwith‘const’qualifier想知道为什么静态成员函数不能声明为const或volatile或constvolatile的原因?#includeclassTest{staticvoidfun()const{//compilererrorreturn;}};

c++ - 错误 : 'std::this_thread' has not been declared

我尝试使用std::this_thread::sleep_for()函数但出现错误错误:“std::this_thread”尚未声明。包含标志_GLIBCXX_USE_NANOSLEEP。还需要什么来强制它工作?MinGW==>gcc版本4.7.2(GCC)中南合作:#includeintmain(){std::this_thread::sleep_for(std::chrono::seconds(3));}命令行:g++-D_GLIBCXX_USE_NANOSLEEP-std=gnu++0xssce.cpp-ossce.exe编译结果:ssce.cpp:Infunction'intm

c++ - Qt Creator编译错误 "::swprintf and::vswprintf has not been declared"

到目前为止,我已经在visualstudio中编写了所有代码,现在我需要向其中添加一些UI,因此我将使用Qt。所以我在我的项目中添加了每个文件(主类除外),然后尝试使用Qt编译它。因为我使用了一些c++0x特性,所以我不得不将这一行添加到项目文件中:QMAKE_CXXFLAGS+=-std=c++0x然后我尝试编译它。只有两个错误(可能还有更多,但编译器在这两个上停止)Infileincludedfromd:\qt\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/bits/postypes.h:42,fromd:\qt\mingw\bin\

c++ - 错误 : '' has not been declared

我正在尝试实现链表,但在编译时出现错误:intSLLst.cpp:38:error:‘intSLList’hasnotbeendeclaredintSLList看起来好像已经向我声明了,所以我真的很困惑。intSLLst.cpp#include#include"intSLLst.h"intintSLList::deleteFromHead(){}intmain(){}intSLLst.h#ifndefINT_LINKED_LIST#defineINT_LINKED_LIST#includeclassIntSLLNode{intinfo;IntSLLNode*next;IntSLLNod

c++ - 错误 : '_hypot' was not declared in this scope

我正在尝试使用GCC和makefile在Windows上编译一个c++程序。我收到以下错误c:\mingw\include\math.h:Infunction'floathypotf(float,float)':c:\mingw\include\math.h:635:30:error:'_hypot'wasnotdeclaredinthisscope{return(float)(_hypot(x,y));}我读到任何包含在GCC上的文件都需要-lm链接器标志。所以我已经将它添加到我的makefile中,但它并没有解决问题......这是我的生成文件CC:=g++CFLAGS:=-std

tcp - 错误 : ‘TCP_NODELAY’ was not declared in this scope

我正在尝试在Ubuntu16.04中编译ChatSciptv7.55。但是当我使用makeserver命令时,我得到了这个错误:evserver.cpp:Infunction‘intsettcpnodelay(int)’:evserver.cpp:263:40:error:‘TCP_NODELAY’wasnotdeclaredinthisscopereturnsetsockopt(fd,IPPROTO_TCP,TCP_NODELAY,(void*)&on,sizeof(on));^Makefile:110:recipefortarget'evserver.o'failedmake:**

swift - Xcode 7.3/swift 2 : "No method declared with Objective-C selector" warning

我使用选择器已有一段时间了,即使在迁移到Swift之后我也能够毫无问题地使用它们。在我将Xcode更新到版本7.3之前,这就是我在Swift2上毫无问题地使用的方式:如用户所见,我将选择器与NSTimer一起使用。这是调用的操作:funcStart(){}如您所见,Xcode7.3现在发出警告“没有使用Objective-C选择器声明的方法”。通过单击警告,Xcode通过添加“选择器”提供了对代码的快速修复,但随后我仍然收到相同的警告: 最佳答案 自Swift2.2/Xcode7.3以来,有一种使用选择器的新方法:Selector(