草庐IT

default-interface-member

全部标签

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++ - C 风格数组与库接口(interface)的 std::array

我想编写一个带有提供读取功能的接口(interface)的库。C风格的数组容易出错,但允许传递任何大小的缓冲区。C++数组更安全,但强制使用大小来构造。//interface.h//C-stylearrayintread(std::uint8_t*buf,size_tlen);//C++arrayintread(std::array&buff)我怎样才能两全其美?我在考虑函数模板,但它对于库接口(interface)来说似乎不实用。templateintread(std::array&buf);编辑std::vector可能是一个很好的候选人,但如果我们考虑到char*和std::ar

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);}好像迭代器返回的是常量对象,不让我

c++ - 为什么智能指针 vector 不是指向实现与该接口(interface)协变的接口(interface)的项目?

为什么智能指针vector不与item实现的接口(interface)协变?例如如果我有一个指向狗的指针vector,为什么我不能将它用作指向iAnimal的指针vector?#include#include#include#includestructiAnimal{virtualstd::stringspeak()const=0;};structiMammal:publiciAnimal{virtualstd::stringspeak()const=0;virtualintlegs()const=0;};structDog:publiciMammal{std::stringspeak

C++ "No appropriate default constructor available"

我想在不使用STL的情况下创建一个数组链表。但是,我在将数组传递到我的链接列表时遇到困难...编译时出现上面列出的错误。我需要如何将数组传递给链表?谢谢!(有问题的代码有**标记,如果测试请去掉)单链表.h#pragmaonce#ifndefSinglyLinkedList_h#defineSinglyLinkedList_h#includetemplatestructnode{Typevalue;node*next;};templateclassSinglyLinkedList{private:node*head;public:SinglyLinkedList();~SinglyLi

c++ - 接口(interface),绝对就是纯虚函数,或者...?

每次我读到接口(interface)时,都会提到它从来没有任何数据成员或实现。但是当我看到带有接口(interface)的代码时,它们两者都有。classIInterface{public:IInterface(){}virtual~IInterface(){}intgetInt(){returnm_int;}virtualvoidBoo()=0;intm_int;};classcInterface:publicIInterface{public:virtualvoidBoo(){printf("definedin.cppforreadability\n");};};classcFoo

c++ - "except that a default constructed array is not empty"是什么意思?

在N3337中,我正在阅读§23.3.2.1/3,它指出:Anarraysatisfiesalloftherequirementsofacontainerandofareversiblecontainer(23.2),exceptthatadefaultconstructedarrayobjectisnotemptyandthatswapdoesnothaveconstantcomplexity.在§23.2.1,表96容器要求中,它显示了一个默认构造的对象Xu;,其中后置条件是u.empty()。据推测,以下内容:std::arraya;应该导致a.empty()输出1,它确实如此。

c++ - 在公共(public)接口(interface)中使用共享指针

我们有一个使用共享指针的非常标准的树API,大致如下所示(为简洁起见省略了实现):classnode;usingnode_ptr=std::shared_ptr;classnode:publicstd::enable_shared_from_this{std::weak_ptrparent;std::vectorchildren;public:virtual~node()=default;virtualvoiddo_something()=0;voidadd_child(node_ptrnew_child);voidremove_child(node_ptrchild);node_pt

c++ - 何时不在 C 中创建单独的接口(interface) (.h) 和实现 (.c)?

关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题?更新问题,以便editingthispost可以用事实和引用来回答它.关闭7年前。Improvethisquestion我目前正在过渡到使用C语言工作,主要专注于开发大型库。我曾使用C++进行大量基于应用程序的编程,尽管我不能声称精通这两种语言。我很好奇的是,许多流行的开源库何时以及为什么选择不将它们的代码与.h文件和相应的.c文件以1-1的关系分开——即使在.c文件不存在的情况下'生成可执行文件。在过去,我被引导相信以这种方式构建代码不仅在组织上是最佳的,而且对于链接目的也是最佳的——我不明白C语言缺少O

c++ - 检查类 T 是否具有带有 void_t 的成员类型 Member

代码如下:templatestructhas_member_type:false_type{};templatestructhas_member_type>:true_type{};structfoo{usingbar=int;};intmain(){std::cout::value;}我正在尝试检查foo是否有bar类型的成员。如果实现不指定类型成员的名称,它工作正常,但这样名称被硬编码到实现中,这对我不起作用。据说重复的问题并不能回答我的问题。正如我在上面的段落中解释的那样,当类型被硬编码到实现中时它很好,但是当我从外部指定类型时我无法让它工作(这是特定问题)。代码编译正常,但产生