草庐IT

METHOD_NAME

全部标签

c++ - template-name<TT> 是推导的上下文吗?

[temp.deduct.type]paragraph8列出所有推断的上下文,但它似乎不包括template-name其中template-name指的是类模板和TT引用模板模板参数。这是推导上下文吗?如果是,为什么?如果不是,请考虑以下代码:templateclassU,templateclassV>structfoo{};templateclassU>structfoo{};intmain(){}此代码编译underClang7.0.0和GCC8.0.1,这意味着编译器认为部分特化比主模板更特化,这意味着U和V在主模板中成功推导出foo.这是编译器错误吗?

c++ - 如何处理QSslSocket : cannot resolve TLSv1_1_client_method error

我正在尝试开发一个可以连接到谷歌地图并使用谷歌地图GPS参数获取map的程序。所以我有一个问题,当我编译代码并单击运行按钮时,我在应用程序输出中看到这些错误:QSslSocket:无法解析TLSv1_1_client_methodQSslSocket:无法解析TLSv1_2_client_methodQSslSocket:无法解析TLSv1_1_server_methodQSslSocket:无法解析TLSv1_2_server_method我在谷歌上搜索了很多但找不到任何答案,我也尝试安装open-sslv1.0.1和v.98但仍然一无所获。我的Qt版本:QtCreator3.0.1

c++ - 用已知数量的元素填充 vector : specify its size in constructor or by using reserve method?

我想通过从流中读取单个元素来创建某种复杂类型的vector。我提前知道vector大小。是在vector构造函数中指定元素个数更好,还是使用reserve方法更好?这两个哪个更好?intmyElementCount=stream.ReadInt();vectormyVector(myElementCount);for(inti=0;i或intmyElementCount=stream.ReadInt();vectormyVector;myVector.reserve(myElementCount);for(inti=0;i如果我只是创建一个intvector或其他一些简单类型呢?

c++ - 存储部分和的二叉树 : Name and existing implementations

考虑n个正实数序列(ai)及其部分和序列(s我)。给定一个数x∊(0,sn],我们必须找到i使得si−1x≤si。也我们希望能够更改ai之一,而不必更新所有部分和。两者都可以在O(logn)时间通过使用二叉树以ai作为叶节点值,非叶节点的值是值的总和各自的child。如果n已知且固定,则树不必是自平衡的并且可以有效地存储在线性数组中。此外,如果n是2的幂,只需要2n-1个数组元素。参见Blue等人,Phys.Rev.E51(1995),pp.R867–R868对于一个应用,鉴于问题的普遍性和解决方案的简单性,我想知道这个数据结构是否有具体的名称,是否有现成的实现(最好是在C++)。我自

c++ - 在 C++ 中为类提供可访问的 "not repeat yourself"时,如何设置 "name"?

考虑以下几点:classBase{public:virtualstd::stringgetName()=0;...};classDerived1:publicBase{public:staticstd::stringgetClassName(){return("Derived1");}std::stringgetName(){return("Derived1");}...};classDerived2:publicBase{public:staticstd::stringgetClassName(){return("Derived2");}std::stringgetName(){re

c++ - 我想我已经重写了一个虚拟方法,但我仍然得到 : "X must implement the inherited pure virtual method Y"

我正在尝试用C++为我正在编写的游戏实现一个接口(interface),但我运行时出错。这是我创建的接口(interface)及其子类://Attack.h//definesasetofvaluesassociatedwithallattacks//andaninterfaceforallattackstypedefunsignedconstintattack_type;typedefunsignedconstintp_attack_type;//definestheattacktypesstaticconstattack_typeNORMAL=0;staticconstattack_

C++ 继承 : Calling virtual method when it has been overridden

我正在尝试构建一个可以在单独的线程中运行(即执行它的run()函数)的service对象。这是服务对象#include#include#include#includeclassservice:publicboost::noncopyable{public:service():stop_(false),started_(false){}virtual~service(){stop();if(thread_.joinable()){thread_.join();}}virtualvoidstop(){stop_=true;}virtualvoidstart(){if(started_.lo

C++11/14/17,GCC 7 与 GCC 8 : Name lookup for friend class templates

我想弄清楚以下代码在GCC7中是否有效,但在GCC8.1中无效。代码的作用是:定义(并转发声明)类模板MyGoodFriend(在全局命名空间中)在inner命名空间中定义一个类模板Befriended使MyGoodFriend的所有特化成为Befriended的friend有问题的部分是templatefriendclassMyGoodFriend;我明白问题是什么了。GCC8.1要求我在friend声明中使用完全限定名称::MyGoodFriend-然而,GCC7对MyGoodFriend很满意。这是代码:templateclassMyGoodFriend;namespaceinn

c++ - (*it)->method() 与 (**it).method

当遍历指针的vector(或其他容器)时,使用以下优势和/或优势之间是否有任何区别:for(it=v.begin();it!=v.end();++it){(*it)->method();}或for(it=v.begin();it!=v.end();++it){(**it).method();} 最佳答案 在C语言中,没有区别。但是,在C++中,->运算符可以被重载,而成员选择.运算符则不能。所以在(*foo)->bar中*foo可以指定一个充当智能指针的类对象,尽管如果这不会发生foo是标准C++指针容器上的迭代器,这意味着*foo

C++ - 错误 : 'list' does not name a type (list object as member variable in class)

关闭。这个问题是notreproducibleorwascausedbytypos.它目前不接受答案。这个问题是由于错别字或无法再重现的问题引起的。虽然类似的问题可能是on-topic在这里,这个问题的解决方式不太可能帮助future的读者。关闭8年前。Improvethisquestion我经常遇到“'xxx'doesnotnameatype”错误,我之前读过的大多数帖子都提到这个错误是由于一些依赖性问题而发生的。但是,我似乎找不到我的。这是我得到的:GameLib.h#ifndefGAMELIB_H_#defineGAMELIB_H_//Structuresstructplayer