草庐IT

private_struct

全部标签

c++ - boost::python: 编译失败,因为复制构造函数是私有(private)的

我使用boost::python来包装一个C++类。此类不允许复制构造函数,但python模块总是想创建一个。C++类看起来像这样(简化)classFoo{public:Foo(constchar*name);//constructorprivate:ByteArraym_bytearray;};ByteArray类继承自boost::noncopyable,因此Foo没有复制构造函数。这是Python模块stub:BOOST_PYTHON_MODULE(Foo){class_("Foo",init());}在编译boost::python模块时,我收到错误,因为ByteArray继承

c++ - 元编程 : Declare a new struct on the fly

是否可以即时声明新类型(空结构体或没有实现的结构体)?例如constexprautomake_new_type()->???;usingA=decltype(make_new_type());usingB=decltype(make_new_type());usingC=decltype(make_new_type());static_assert(!std::is_same::value,"");static_assert(!std::is_same::value,"");static_assert(!std::is_same::value,"");“手动”解决方案是template

c++ - 元编程 : Declare a new struct on the fly

是否可以即时声明新类型(空结构体或没有实现的结构体)?例如constexprautomake_new_type()->???;usingA=decltype(make_new_type());usingB=decltype(make_new_type());usingC=decltype(make_new_type());static_assert(!std::is_same::value,"");static_assert(!std::is_same::value,"");static_assert(!std::is_same::value,"");“手动”解决方案是template

C++ 私有(private)类成员变量没有出现在文档中

类记录如下:/***@briefNumberrepresentation*/classCNumber:publicCElem{/**@briefHoldstruefornegativevalues*/boolneg;...但是,代码中记录的变量没有出现在文档中(类摘要显示正常...)。我做错了什么? 最佳答案 这是私有(private)的。使其公开或protected,它会显示出来,或者通过在配置文件(通常是“Doxyfile”)中将EXTRACT_PRIVATE标记设置为YES来配置Doxygen以显示私有(private)成员)

C++ 私有(private)类成员变量没有出现在文档中

类记录如下:/***@briefNumberrepresentation*/classCNumber:publicCElem{/**@briefHoldstruefornegativevalues*/boolneg;...但是,代码中记录的变量没有出现在文档中(类摘要显示正常...)。我做错了什么? 最佳答案 这是私有(private)的。使其公开或protected,它会显示出来,或者通过在配置文件(通常是“Doxyfile”)中将EXTRACT_PRIVATE标记设置为YES来配置Doxygen以显示私有(private)成员)

c++ - 在类外调用的私有(private)函数成员

在下面的例子中,为什么B::f()被调用,即使它是私有(private)的?我知道这个事实:在调用点使用用于表示调用成员函数的对象的表达式类型检查访问。#includeclassA{public:virtualvoidf(){std::cout 最佳答案 因为标准是这样说的:[C++11:11.5/1]:Theaccessrules(Clause11)foravirtualfunctionaredeterminedbyitsdeclarationandarenotaffectedbytherulesforafunctionthatl

c++ - 在类外调用的私有(private)函数成员

在下面的例子中,为什么B::f()被调用,即使它是私有(private)的?我知道这个事实:在调用点使用用于表示调用成员函数的对象的表达式类型检查访问。#includeclassA{public:virtualvoidf(){std::cout 最佳答案 因为标准是这样说的:[C++11:11.5/1]:Theaccessrules(Clause11)foravirtualfunctionaredeterminedbyitsdeclarationandarenotaffectedbytherulesforafunctionthatl

c++ - 在 B 类中声明为友元的 A 类成员模板函数无法访问 A 类的私有(private)成员(仅限 Clang)

请查看此代码段。我知道这没有多大意义,只是为了说明我遇到的问题:#includeusingnamespacestd;structtBar{templatevoidPrintDataAndAddress(constT&thing){cout(thing);}private://friendstructtFoo;//fixesthecompilationerrortemplatevoidPrintAddress(constT&thing){cout(consttFoo&);private:intmData=42;};structtWidget{intmData=666;};intmain(

c++ - 在 B 类中声明为友元的 A 类成员模板函数无法访问 A 类的私有(private)成员(仅限 Clang)

请查看此代码段。我知道这没有多大意义,只是为了说明我遇到的问题:#includeusingnamespacestd;structtBar{templatevoidPrintDataAndAddress(constT&thing){cout(thing);}private://friendstructtFoo;//fixesthecompilationerrortemplatevoidPrintAddress(constT&thing){cout(consttFoo&);private:intmData=42;};structtWidget{intmData=666;};intmain(

c++ - 为什么 typedef struct 会产生链接失败

所以我有一段看起来像这样的代码。typedefstruct{intfoo;intbar;voidfoobar(int,char*);}mystruct;和voidmystruct::foobar(intx,char*y){return;}和mystructobj;obj.foobar(17,"X");这一切都可以完美地编译、链接和运行。除非它没有。在一个编译器上它可以工作,而在另一个编译器(AndroidGCC)上它失败并出现链接错误:不满意的引用。如果我这样更改它,它会编译并链接。structmystruct{intfoo;intbar;voidfoobar(int,char*);}