草庐IT

without_protection

全部标签

c++ - 服务器端警告 : Aggregation query used without partition key

在使用Cassandra的C/C++驱动程序时,我有时会在控制台中看到此类消息:1460937092.140[WARN](src/response.cpp:51:char*cass::Response::decode_warnings(char*,size_t)):Server-sidewarning:Aggregationqueryusedwithoutpartitionkey想知道是否有人知道这意味着什么。我应该在我的代码中寻找什么会产生这个错误,或者它只是服务器端我无法控制的东西? 最佳答案 该警告告诉您,您正在使用没有分区键

C++ 指针 : changing the contents without changing the address?

MyCustomObject*object=newMyCustomObject();假设我的许多类都使用了对象指针,但突然间我想在不更改地址的情况下更改指针的内容。我认为object=newMyCustomObject()会给对象一个新的指针地址是不是错了?我想要新对象而不更改指针地址(是的,我会确保清理旧对象)。 最佳答案 通常最好更改对象的属性(通过调用其方法)而不是删除它并创建一个新对象。特别是可以完全通过赋值来替换对象,如:*object=MyCustomObject();//Replaceobjectwiththeresu

c++ - 为什么 GoF 建议在 C++ 模板方法模式实现中使用 protected (而不是私有(private))虚拟方法?

来自四人组的模板方法模式:Threeimplementationissuesareworthnoting:UsingC++accesscontrol.InC++,theprimitiveoperationsthatatemplatemethodcallscanbedeclaredprotectedmembers.Thisensuresthattheyareonlycalledbythetemplatemethod.Primitiveoperationsthatmustbeoverriddenaredeclaredpurevirtual.Thetemplatemethoditselfsh

c++ - union 内的 'protected' 关键字有什么用?

这个问题在这里已经有了答案:Whatisthepointof'protected'inaunioninC++(1个回答)关闭7年前。我检查了protected访问说明符可以在class、struct以及union中使用。我知道protected访问说明符意味着成员将是私有(private)的,但对派生类可见。我无法想到一个合理的用例,其中union内的protected关键字会很有用,因为union不能成为继承层次结构的一部分。既然在union中private和protected没有区别,为什么还要在union中允许protected呢? 最佳答案

c++ - 嵌套类 : Access to protected member of enclosing class from a nested protected class

此代码在msvc/g++上编译:classA{protected:inti;classB{public:A*a;B(A*a_):a(a_){}voiddoSomething(){if(a)a->i=0;//如您所见,B可以访问封闭类的“protected”部分,尽管它没有被声明为友元。这是一种标准(符合标准的)行为吗?我有时会使用此功能,但我不记得有一条规则说嵌套的protected类应该自动访问封闭类的所有protected数据。 最佳答案 在C++03标准中,11.8p1说:Themembersofanestedclasshav

c++ - 终止 protected 防病毒进程

我正在使用ESet防病毒软件,最近它的GUI前端egui.exe挂起,占用了50%的CPU(即一个内核的100%)。令人惊讶的是,我发现我无法杀死它,即使启用了调试权限。现在我很好奇:他们是如何实现这样的防御的,有没有办法在不写内核驱动的情况下杀死它?egui.exe进程在普通用户(非管理员)下运行,我尝试使用管理帐户以各种方式杀死它。这是我尝试过的。你不能从任务管理器中杀死它你无法使用pskill杀死它您不能使用进程资源管理器将其杀死,也不能将调试器附加到它然后我开始了一些编程,发现:在非特权用户下,您可以使用PROSESS_TERMINATE访问权限打开它,但对TerminateP

c++ - g++编译错误 "... is protected from within this context",而clang没有错误

我有以下代码:#includeclassBaseClass{protected:staticintx;};intBaseClass::x;classDerivedA:publicBaseClass{public:DerivedA(){x=3;}};classDerivedB:publicBaseClass{public:DerivedB(){std::cout使用g++编译(g++classtest.cpp)我收到以下错误:classtest.cpp:Inconstructor‘DerivedB::DerivedB()’:classtest.cpp:9:5:error:‘intBase

c++ - 有效 C++ : discouraging protected inheritance?

我正在阅读ScottMeyers的EffectiveC++(第三版),并在第32项:确保公共(public)继承是页面上的“is-a”中的一段中151他发表评论(我用粗体表示):Thisistrueonlyforpublicinheritance.C++willbehaveasI'vedescribedonlyifStudentispubliclyderivedfromPerson.Privateinheritancemeanssomethingentirelydifferent(seeItem39),andprotectedinheritanceissomethingwhosemea

c++ - 无法访问派生类中基类的 protected 成员

我有以下代码:structA{protected:A(){}A*a;};structB:A{protected:B(){b.a=&b;}Ab;};奇怪的是它不能编译。罪魁祸首是b.a=&b;赋值:GCC和clang都提示A()受到保护,这应该不是问题,因为B继承了A。我已经进入标准的角落了吗? 最佳答案 protected的含义是派生类型可以访问它自己的基类的成员,而不是任何随机对象*的成员。在您的情况下,您关心尝试修改b的成员不在您的控制范围内(即您可以设置this->a,但不能设置b.a)如果您有兴趣,有一个hack可以让它工作

c++ - protected 成员是派生类中的 "not declared in this scope"

这个问题在这里已经有了答案:accessingprotectedmembersofsuperclassinC++withtemplates[duplicate](2个回答)关闭8年前。#include#includetemplateclassBase{protected:std::vectordata_;};templateclassDerived:publicBase{public:voidclear(){data_.clear();}};intmain(intargc,char*argv[]){Derivedderived;derived.clear();return0;}我无法编