草庐IT

ibm-cloud-private

全部标签

c++ - 私有(private)方法作为尾随返回类型 (decltype)

当我尝试在私有(private)方法函数上使用decltype()时,我得到了私有(private)方法error:'m1'hasnotbeendeclaredinthisscope#includeclassC{public:C()=default;~C()=default;automasterMethod(intopMode)->decltype(m1()){switch(opMode){case1:returnm1();break;case2:returnm2();break;default:returnm1();break;}}private:intm1(){return1;}i

c++ - 翻译单位可以私有(private)类(class)吗?

考虑以下代码:/**myclass.h*/classmyclass_impl{//...}boost::shared_ptrmyclass;我能否以某种方式使myclass_impl(或至少直接使用它)对定义它的翻译单元私有(private),从而允许客户仅使用myclass类型定义?我想要实现的是让编译器在有人直接使用实现类时提醒我。 最佳答案 在源文件(不是头文件)中声明您的类,其他翻译单元将无法访问它。然后,使用前向声明在头文件中声明指针/引用。或者定义一个impl头文件,并注释掉它不应该包含在其他源文件中。/**myclas

c++ - 无法使 C++ 中的私有(private)方法返回指向私有(private)嵌套类的指针

这个不想编译:classMainClass{public:...private:classNestedClass{//Line39...};classNestedClass*getNestedClassFor(inti);};编译器说:error:'classMainClass::NestedClass'isprivate但是,如果我将NestedClass设置为public,它就会起作用。为什么不起作用?这不是好像我正在通过公共(public)方法导出嵌套类吗?它只是一个私有(private)方法,返回一个指向私有(private)类的指针。有什么想法吗?谢谢!更新修复了半列。他们不

涉及私有(private)继承的 C++ 编译器错误

有人可以向我解释以下编译器错误吗:structB{};templatestructA:privateT{};structC:publicA{C(A);//ERRORHERE};指定行的错误是:test.cpp:2:1:error:'structBB::B'isinaccessibletest.cpp:12:7:error:withinthiscontext究竟什么是不可访问的,为什么? 最佳答案 尝试A或A.内部C,对B的不合格引用将获取所谓的injected-class-name,它是通过基类引入的A.自A私有(private)继

为什么Gopath不被Google-Cloud-SDK Go-App-Stager识别?

当我尝试更新我的附录项目时,它会给我一个错误。$sudogcloudappdeployERROR:(gcloud.app.deploy)Stagingcommand[/usr/local/google-cloud-sdk/platform/google_appengine/goroot-1.6/bin/go-app-stager/Users/baz/app/app.yaml/tmp/tmpSZLK/tmpIQ4]failedwithreturncode[1].------------------------------------STDOUT--------------------------

c++ - 初始化类的私有(private)成员变量

我提前道歉,因为我的一些措辞可能不是100%正确。我要上这样一个类:classClassName{private:AnotherClassclass2;public:ClassName();~ClassName();...在这个类的构造函数中,除其他外,我放了一行ClassName::ClassName(){AnotherClassclass2;}这就是我认为您应该在C++中初始化对象的方式,但是我注意到(通过GDB)正在创建两个AnotherClass对象。一次在构造函数定义上,然后再次在我的初始化行上。这背后的原因是什么?如果我想使用一个更复杂的构造函数,比如AnotherClas

c++ - 如何为二维数组编写访问器(私有(private)成员)

我有一个名为mat[3][3]的类的私有(private)成员,我希望能够在我的类之外访问这个3x3数组(只读取它,而不是更改它)。是否可以编写返回指向我的数组的指针的访问器方法?我怎样才能做到这一点?请提供代码示例。这是我的类(class):classmyClass{private:intmat[3][3];public:return_valueget_mat(void);};我知道我可以使用类似的东西intget_mat(inti,intj);一个一个地访问数组中的每个int,但是为数组的每个成员调用访问器会不会效率低下? 最佳答案

C++: Cloud computing library: 有这样一个库,我不需要写太多网络的东西吗?

我希望我的服务器应用程序能够发送数据以供各种客户端处理,然后将处理后的数据返回给服务器。理想情况下,我会有一些像some_process=send_to_client_for_calculating(connection,data)这样的调用我只需要能够向客户端发送一堆数据,告诉客户端要做什么(最好在同一条消息中,这可以用数组[command,data]来完成),然后返回数据...我正在分解神经网络的各个部分(非常大),然后再将它们组装起来。如果我需要更清楚一点,请告诉我怎么做。 最佳答案 我很震惊没有人把它扔出去......boo

c++ - 确定 C++ 类是否具有私有(private)析构函数

假设我有以下代码:classExample{#ifndefPRIVATE_DESTRUCTORpublic:#endif~Example(){}public:friendclassFriend;};classFriend{public:voidMember();};voidFriend::Member(){std::printf("Example'sdestructoris%s.\n",IsDestructorPrivate::value?"private":"public");}是否可以实现上面的IsDestructorPrivate模板来确定类的析构函数是private还是prot

c++ - 通过 using 指令公开私有(private)继承的内部模板

我正在尝试使用using引入public的指令派生类的访问声明一些在基类中声明的内部类模板。代码:templateclassBase{public:templatestructInner;};templateclassDerived:privateBase{public:usingtypenameBase::templateInner;//makeitvisibleInner*ptr;//noneedfortypenamehere,non-qualifiedname};intmain(){}g++和clang++都不编译这段代码,都提示error:expectedunqualified