草庐IT

member-hiding

全部标签

c++ - 模板化线性代数 vector 类中出现奇怪的 "Member function not viable"错误

我正在实现一个模板化vector类(不是数据容器,而是线性代数意义上的vector),每当我引用rhs时都会遇到很多错误。在我的运算符重载中。另外,我的复制构造函数似乎不起作用。#ifndef__VecXd__VecXd__#define__VecXd__VecXd__#defineULLunsignedlonglong#includeusingnamespacestd;templateclassVecXd{public:explicitVecXd(ULLnewDimension=1){dimension=newDimension;vector=newT[newDimension];}

c++ - "smart pointer to member"的真实示例是什么?

为了澄清英语中可能存在的优先级歧义:我们正在讨论“智能(指向成员的指针)”,而不是“指向成员的(智能指针)”。我会将指向成员的智能指针定义为带有operator->*(T*lhs,Xrhs)的类X。在他的文章"Implementingoperator->*forSmartPointers",ScottMeyers只是简单地触及smart指向成员的指针,因为当时(1999年)具体问题对于原始指向成员的指针(旁注:后者可以用lambdahere优雅地解决)。无论如何,ScottMeyers在脚注中写道:Shortlyafterwritingthedraftofthisarticle,one

c++ - 如何查找窗口的 SW_SHOW/SW_HIDE 状态

我正在尝试确定已使用CWnd::ShowWindow()隐藏或启用的窗口控件的可见性。(或::ShowWindow(hWnd,nCmdShow))我不能简单地使用::IsWindowVisible(hWnd),因为控件位于选项卡上,它本身可能会被切换,导致IsWindowVisible返回FALSE。有没有办法获得SW_SHOW/HIDE(或其他)窗口状态,还是我需要使用ShowWindow()的retun值并相应地重置?编辑:由于控件已启用(或禁用)以显示,但当前可能不可见,因为选项卡已切换,我认为它的SW_SHOW状态将保持不变,即使窗口本身实际上并未打开。如果我的期望是不现实的。

c++ - Doxygen 警告 : no uniquely matching class member found for

我将Doxygen用于C++项目。在构建html文档时,出现以下错误:C:/Amir/Programming/EclipseC++/CacheOptimization/src/CacheLruNaiveAlgorithm.cpp:19:warning:nouniquelymatchingclassmemberfoundforvoidCacheOpt::CacheLruNaiveAlgorithm::init(TierList&tierList,TierMap*tierMap)此警告的来源可能是什么?一般是什么原因造成的?编辑:我的DoxyfileDOXYFILE_ENCODING=UT

c++ - 错误 : ISO C++ forbids in-class initialization of non-const static member

这是头文件:employee.h#ifndefEMPLOYEE_H#defineEMPLOYEE_H#include#includeusingnamespacestd;classEmployee{public:Employee(conststring&first,conststring&last)重载的构造函数:firstName(first),firstName重载构造函数lastName(last)lastName重载构造函数{//Theconstructorstart++counter;它为每个创建的对象加一;cout析构函数cout返回每个对象的名字和姓氏--counter;计

c++ - 错误 : 'sort' is not a member of 'std'

我只是想问一下这个错误是什么意思以及如何解决它谢谢!error:'sort'isnotamemberof'std'vectorresult;for(auto&i:numbers)result.push_back(std::stoi(i));std::sort(result.begin(),result.end()); 最佳答案 包括算法头。这就是出现错误的原因。#include 关于c++-错误:'sort'isnotamemberof'std',我们在StackOverflow上找到一

C++ 错误 - "member initializer expression list treated as compound expression"

我遇到了一个我不熟悉的C++编译器错误。可能是一个非常愚蠢的错误,但我不能完全指出它。错误:test.cpp:27:error:memberinitializerexpressionlisttreatedascompoundexpressiontest.cpp:27:warning:left-handoperandofcommahasnoeffecttest.cpp:27:error:invalidinitializationofreferenceoftype‘constBar&’fromexpressionoftype‘int’代码:1#include23classFoo{4publ

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++ - 智能感知 : the object has type qualifiers that are not compatible with the member function

我有一个名为Person的类:classPerson{stringname;longscore;public:Person(stringname="",longscore=0);voidsetName(stringname);voidsetScore(longscore);stringgetName();longgetScore();};在另一个类(class),我有这个方法:voidprint()const{for(inti=0;i这是人的声明:staticconstintsize=8;Personpeople[size];当我尝试编译它时,我得到了这个错误:IntelliSense

c++ - 初始化引用 - 警告 C4355 : 'this' : used in base member initializer list

classA;classB{public:B(A&a):a(a){}private:A&a;};/*Method1*//*warningC4355:'this':usedinbasememberinitializerlist*//*classA{public:A():b(*this){}private:Bb;};*//*Method2*//*ButIneedtomanuallyperformmemorydellocation.*/classA{public:A(){b=newB(*this);}~A(){deleteb;}private:B*b;};intmain(){}目前,当我尝试