草庐IT

more-private

全部标签

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++ - 私有(private)嵌套类 c++ 的实例

这个问题在这里已经有了答案:WhycanIuseautoonaprivatetype?(5个回答)关闭7年前。我有以下代码classA{private:classB{public:voidf(){printf("Test");}};public:Bg(){returnB();}};intmain(){Aa;A::Bb;//CompilationerrorC2248A::Bb1=a.g();//CompilationerrorC2248autob2=a.g();//OKa.g();//OKb2.f();//OK.Outputis"Test"}如您所见,我有A类和私有(private)嵌套

c++ - 私有(private)嵌套类 c++ 的实例

这个问题在这里已经有了答案:WhycanIuseautoonaprivatetype?(5个回答)关闭7年前。我有以下代码classA{private:classB{public:voidf(){printf("Test");}};public:Bg(){returnB();}};intmain(){Aa;A::Bb;//CompilationerrorC2248A::Bb1=a.g();//CompilationerrorC2248autob2=a.g();//OKa.g();//OKb2.f();//OK.Outputis"Test"}如您所见,我有A类和私有(private)嵌套

c++ - 访问私有(private)嵌套类

我做了这个简单的类(class),但我仍然在玩:classA{private:classB{};public:BgetB(){returnB();};};从C++03开始​​,这个类编译得很好,但是没有漂亮的方法将getB()的结果分配给一个左值,在感觉:A::Bb=A().getB();不编译。我通过使用中间模板得到它,以这种方式:templatestructHideType{typedefTtype;};HideType::typeb=A().getB();但这看起来很糟糕,对于获取A::B左值变量的简单任务。从C++11开始,这不再是真的,或者至少在gcc中不是这样。此代码仍然无

c++ - 访问私有(private)嵌套类

我做了这个简单的类(class),但我仍然在玩:classA{private:classB{};public:BgetB(){returnB();};};从C++03开始​​,这个类编译得很好,但是没有漂亮的方法将getB()的结果分配给一个左值,在感觉:A::Bb=A().getB();不编译。我通过使用中间模板得到它,以这种方式:templatestructHideType{typedefTtype;};HideType::typeb=A().getB();但这看起来很糟糕,对于获取A::B左值变量的简单任务。从C++11开始,这不再是真的,或者至少在gcc中不是这样。此代码仍然无