草庐IT

member_joindate

全部标签

C++ 私有(private)函数 : Whether to pass class member variable by function parameter, 或不

这是一个在C++类实现中反复出现的问题。我很好奇人们在这里的想法是什么。您更喜欢哪种代码,为什么?classA{public:/*Constructors,Destructors,Publicinterfacefunctions,etc.*/voidpublicCall(void);private:voidf(void);CMyClassm_Member1;};与voidA::publicCall(void){f();}voidA::f(void){//dosomestuffpopulatingm_Member1}或者替代方案:classA{public:/*Constructors,

c++ - Visual Studio 2015 "non-standard syntax; use ' &' to create a pointer to member"

我正在尝试用C++实现自己的链表,但终究无法弄清楚为什么会出现此错误。我知道有一个STL实现,但出于某种原因,我正在尝试自己的实现。这是代码:#includetemplateclassListElement{public:ListElement(constT&value):next(NULL),data(value){}~ListElement(){}ListElement*getNext(){returnnext;}constT&value()const{returnvalue;}voidsetNext(ListElement*elem){next=elem;}voidsetValu

c++ - 线程错误 : invalid use of non-static member function

这个问题在这里已经有了答案:Passingmemberfunctionstostd::thread[duplicate](2个答案)关闭5年前。我想了解C++中的线程,但我不知道如何解决这个问题。我想调用两个线程来运行名为“createS”的函数,但出现此错误:error:invaliduseofnon-staticmemberfunction我读过关于这个主题的其他问题,但我真的不明白如何让我的代码工作。有人可以向我解释我做错了什么并尝试帮助我找到解决方案吗?test_class.cppvoidtest_class::generateS(){map1=newmultimap>;map

c++ - 编译错误error C2039 : 'clock_t' : is not a member of '` global namespace''

我在VS2010中使用boost1_53进行编译。我也在使用boost的线程。在编译过程中我遇到了一堆这样的错误c:\programfiles(x86)\microsoftvisualstudio10.0\vc\include\ctime(18):errorC2039:'clock_t':isnotamemberof'`globalnamespace''所有错误都是关于ctime和c_time.hpp。我四处寻找解决方案但没有成功。谁能帮忙吗?这里是部分代码。#defineBOOST_THREAD_USE_DLL#include#include#include#include#incl

android - 错误 : 'to_string' is not a member of 'std'

它可能是重复的,但我尝试了我在StackOverflow内外找到的所有解决方案。我正在使用OpenCV在C++上创建一个库,并尝试为Android编译它。我不能使用to_string(int)但我不能。我试图多次修改我的makefile。我最后的配置是:Android.mkLOCAL_PATH:=$(callmy-dir)include$(CLEAR_VARS)OPENCV_CAMERA_MODULES:=offOPENCV_INSTALL_MODULES:=oninclude$(LOCAL_PATH)/jsoncpp/Android.mkinclude/Users/rafaelrui

C++ - 错误 : 'list' does not name a type (list object as member variable in class)

关闭。这个问题是notreproducibleorwascausedbytypos.它目前不接受答案。这个问题是由于错别字或无法再重现的问题引起的。虽然类似的问题可能是on-topic在这里,这个问题的解决方式不太可能帮助future的读者。关闭8年前。Improvethisquestion我经常遇到“'xxx'doesnotnameatype”错误,我之前读过的大多数帖子都提到这个错误是由于一些依赖性问题而发生的。但是,我似乎找不到我的。这是我得到的:GameLib.h#ifndefGAMELIB_H_#defineGAMELIB_H_//Structuresstructplayer

c++ - 成员初始化列表 : initialize two members from a function returning a tuple

memberinitializerlist中的多个成员是否可以从函数获得的元组中初始化?随着通过元组返回多个值变得越来越流行,我希望有一个解决方案。除了语言限制,我看不出有什么其他原因无法做到这一点。这是我所拥有的mcve:autonew_foo(std::size_tsize)->std::tuple,int*>{autobuffer=std::make_unique(size*sizeof(int)+8);autobegin=static_cast(static_cast(buffer.get()+4));returnstd::make_tuple(std::move(buffer

c++ - 'struct std::pair<int, int >' has no member named ' 序列化'

我正在尝试将序列化集成到我的代码中。但是,我收到“没有命名的成员”错误。我正在阅读的书说std::pair不需要包含头文件并且不存在。如何修复此错误?我的代码如下所示:#include//ofstream/ifstream#include#include#include//stringstream#include//#include#include//#includeusingnamespacestd;intmain(){complexc(1,0);bitsetb(BOOST_BINARY(101));pairp(1,2);strings;std::stringstreamss(s);

c++ - 在 Mac 上安装 xgboost 失败 - ar : no archive members specified

我正在尝试在Mac上安装xgboost。我按照github上的说明进行操作,但是当我运行make-j4时出现错误:c++-std=c++0x-Wall-O3-msse2-Wno-unknown-pragmas-funroll-loops-Iinclude-Idmlc-core/include-Irabit/include-fPIC-DDISABLE_OPENMP-oxgboostbuild/cli_main.obuild/learner.obuild/logging.obuild/c_api/c_api.obuild/c_api/c_api_error.obuild/common/co

c++ - 类型特征 : Check if reference member variable is static or not

我想检查一个类的成员变量是否是静态的。使用std::is_member_pointer适用于除引用成员之外的所有类型。#includestructA{intfoo;};structB:A{};structC{staticintfoo;};structD:C{};structE{int&foo;};structF{staticint&foo;};static_assert(std::is_member_pointer::value,"No");static_assert(std::is_member_pointer::value,"No");static_assert(!std::is_