草庐IT

has_public_member_foo

全部标签

c++ - 为什么在使用命名空间 foo 时不能在 sub::bar 中使用 foo::bar 函数?

考虑以下程序:namespacefoo{namespacesub{intf();}//namespacesub}//namespacefoonamespacebar{namespacesub{intg(){usingnamespacefoo;returnsub::f()+1;}}//namespacesub}//namespacebar我希望它能编译,但它没有:$g++-6-ca.cppa.cpp:Infunction‘intbar::sub::g()’:a.cpp:12:9:error:‘f’isnotamemberof‘bar::sub’returnsub::f()+1;^~~a.

java - 公共(public)方法中的私有(private)参数

当非私有(private)方法的参数是私有(private)类型(例如,私有(private)嵌套类)时,g++和javac都不会发出警告。此类方法不能由客户端使用,但它们可以作为类的公共(public)API的一部分出现。在C++中,将此类方法放入类Foo的公共(public)部分,例如,可以允许其他类访问这些方法,而无需明确列为类Foo中的友元(只要它们可以访问用作参数)。但总的来说,不显式地将此类方法设为私有(private)是否是不好的风格,还是可以将其忽略?(反正客户端用不了,有什么大不了的) 最佳答案 这是允许的,也可能

c++ - 警告 C4180 : qualifier applied to function type has no meaning; ignored

我已经设置了编译器/Za选项来禁用语言扩展,以便编译器严格使用标准ISOC++。这是我收到以下警告的示例接口(interface)类warningC4180:qualifierappliedtofunctiontypehasnomeaning;ignored这是关于函数返回类型中的const限定符,如果我删除const,警告就会消失,但我不想这样做,我想重新启用lanqage扩展。我的问题是:这个警告合理吗?如果不是,那么我将使用pragma禁用警告,但在此之前我想确保此警告是“误报”因为下面的类是正确的ANSIISOC++不是吗?所以警告应该被禁用?classIBet{public:

c++ - 错误 C2995 : function template has already been defined

此代码产生17错误C2995:函数模板已被定义;在添加#include"set.h"header之前存在一组单独的错误。有一个与此关联的私有(private).cpp和.h文件。/**File:private/set.cpp*LastmodifiedonThuJun1109:34:082009byeroberts*-----------------------------------------------------*Thisfilecontainstheimplementationoftheset.hinterface.*BecauseofthewayC++compilestemp

c++ - Qt5 : error: 'WA_LockPortraitOrientation' is not a member of 'Qt'

我正在尝试将Qt4/Symbian项目编译为Qt5,同时保留对Qt4/Symbian的支持。目前MainWindow::setOrientation自动生成的样板函数给我带来了麻烦。它给我这些编译器错误:error:'WA_LockPortraitOrientation'isnotamemberof'Qt'error:'WA_LockLandscapeOrientation'isnotamemberof'Qt'error:'WA_AutoOrientation'isnotamemberof'Qt' 最佳答案 是的,正如您自己所说,这

c++ - 如何优化最长公共(public)子序列的 O(m.n) 解决方案?

给定两个字符串,长度为x1的字符串X和长度为y1的字符串Y,找出两个字符串中从左到右(但不一定在连续block中)出现的最长字符序列。e.gifX=ABCBDABandY=BDCABA,theLCS(X,Y)={"BCBA","BDAB","BCAB"}andLCSlengthis4.我使用了这个问题的标准解决方案:if(X[i]=Y[j]):1+LCS(i+1,j+1)if(X[i]!=Y[j]):LCS(i,j+1)orLCS(i+1,j),whicheverisgreater然后我使用了内存,使它成为一个标准的DP问题。#include#includeusingnamespace

c++ - 如何计算最小公共(public)祖先算法的时间复杂度?

我进入了一篇讲LCA算法的文章,代码很简单http://leetcode.com/2011/07/lowest-common-ancestor-of-a-binary-tree-part-i.html//Return#nodesthatmatchesPorQinthesubtree.intcountMatchesPQ(Node*root,Node*p,Node*q){if(!root)return0;intmatches=countMatchesPQ(root->left,p,q)+countMatchesPQ(root->right,p,q);if(root==p||root==q)

c++ - 错误 : 'ios_base' has not been declared

我正在使用libcurl下载序列化代码并将其打开,但是,我收到一个错误,看起来fstream丢失了,但它包含在内。我环顾四周,但很少发现错误。下面是错误和代码。错过了什么?编译错误输出g++-gtestGetprice2.cpp-otestGetprice2.o-std=gnu++11-lcurltestGetprice2.cpp:Infunction'intgetData()':testGetprice2.cpp:45:56:error:'ios_base'hasnotbeendeclaredtestGetprice2.cpp:45:72:error:'ios_base'hasnot

c++ - 错误 : imread is not a member of cv

我使用OpenCV3.0和Ubuntu14.04。我正在尝试使用opencv在ubuntu上编译一些代码。我收到错误"error:'imread'isnotamemberof'cv'"由于我以前的搜索知识,我尝试通过添加“highgui.h”进行编译。我使用:$g++main.cppHOG.cppHOGFeaturesOfBlock.cpp-I/usr/local/include/opencv-lml-lcvaux-highgui-lcv-lcxcore-ofeatureExtractor在终端上编译。有什么建议吗?问候。可以。 最佳答案

c++ - 错误 : no matching member function for call to 'push_back'

为什么我在最后两行收到错误?目标是在集合中找到对象,并修改其内容。usingnamespacestd;structmystruct{intid;vectory;mystruct(constintid):id(id){}booloperatorsx;mystructx(1);x.y.push_back(1);x.y.push_back(2);sx.insert(x);//set::iteratori=sx.find(1);constmystruct*x1=&(*i);constmystructx2=*x1;couty)y)y.push_back(4);}好像迭代器返回的是常量对象,不让我