草庐IT

default-interface-member

全部标签

c# - 在 .NET 中派生 COM 接口(interface)

由于我无法控制的公司限制,我有以下情况:定义以下接口(interface)的COM库(没有CoClass,只有接口(interface)):[object,uuid(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx),dual,nonextensible,helpstring("IServiceInterface"),pointer_default(unique)]IService:IDispatch{HRESULTDoSomething();}[object,uuid(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx),dual,non

c++ - 如何编写具有 cout 样式接口(interface)的记录器类 (logger << "Error: "<< val << endl;)

我想创建一个具有如下功能的记录器类:Loggerlog;log这应该给我打印一条自定义格式的消息。例如。“12-09-200911:22:33看到错误5”我的简单类目前看起来像这样:classLogger{private:ostringstreamoss;public:templateLogger&operatorLogger&Logger::operator这将导致oss正确地拥有缓冲区“Error:5seen”。但我不知道我还需要编写/修改什么其他功能才能在屏幕上打印某些内容。有谁知道如何让它工作,或者是否有另一种方法来设计这个类来让我的功能正常工作?

c++ - C++是否有不使用vtable的接口(interface)的静态多态实现?

C++是否有不使用vtable的正确接口(interface)实现?例如classBaseInterface{public:virtualvoidfunc()const=0;}classBaseInterfaceImpl:publicBaseInterface{public:voidfunc(){std::coutfunc();最后一行对func的调用转到vtable以查找BaseInterfaceImpl::func的funcptr,但是是否有任何C++方法可以直接执行此操作,因为BaseInterfaceImpl不是纯接口(interface)类之外的任何其他类的子类基础接口(in

c++ - "pure virtual method called"实现 boost::thread 包装器接口(interface)时

我有一个小包装器,它集中了与线程相关的内容:classThread{protected:boost::thread*m_thread;virtualvoidwork()=0;voiddo_work(){work();}public:Thread():m_thread(NULL){}virtual~Thread(){catch_up();deletem_thread;}inlinevoidcatch_up(){if(m_thread!=NULL){m_thread->join();}}voidrun(){m_thread=newboost::thread(boost::bind(&Thr

c++ - CString 'Trim' : is not a member, 为什么?

我有一个简单的应用程序,我尝试用VCExpress编译并使用:适用于WindowsServer2003的Microsoft平台SDK,包含MFC和ATL。现在我有了这个简单的代码:CStringstrValue("test");CStrings=strValue.Trim();LPCTSTRlpStr=(LPCTSTR)strValue.Trim()这给我一个编译错误:c:\dev\test.cpp(463):errorC2039:'Trim':不是'CString'的成员c:\programfiles\microsoftplatformsdkforwindowsserver2003r

c++ - C++中的类接口(interface)继承

我有以下情况,图为我的类的理论继承图:基本思路是1)有两个可以在不同平台上实现的抽象基类(在我的例子中是两个不同的操作系统)2)允许BBase向上转换为ABase以便有时能够平等地处理这两种类型(例如,将两种类型的实例保存在一个列表中)。3)在ABase和BBase中实现某些通用功能。现在,用C++表示它的最佳方式是什么?尽管它确实支持多重继承,但据我所知,像这样的多级继承是不可能的。问题是B继承自A和BBase,而后者又继承自ABase。只需将此1:1(以下代码)翻译成C++,C++编译器(GNU)就会提示ABase::foo()未在B中实现。classABase{public:vi

c++ - 模板函数 : default construction without copy-constructing in C++

考虑structC{C(){printf("C::C()\n");}C(int){printf("C::C(int)\n");}C(constC&){printf("copy-constructed\n");}};还有一个模板函数templatevoidfoo(){//default-constructatemporaryvariableoftypeT//thisiswhatthequestionisabout.Tt1;//willbeuninitializedfore.g.int,float,...Tt2=T();//willcalldefaultconstructor,thenco

c++ - 访客模式。 void* 是完全抽象接口(interface)可接受的返回类型吗?

我有一个AST,以通常的方式表示(抽象类型的节点树)。我有几个遍历这棵树的用例(一个优化器,它返回另一个AST;IR代码生成,它返回一个llvm::Value*;和一个调试分析器,它简单地输出到stdout并返回什么都没有)。访问者感觉去这里是正确的方式,但是访问者的每个用例的不同返回类型使得很难看出如何为此实现接口(interface)。我考虑过这个:classVisitor;classASTNode{public:virtualvoidaccept(Visitor*visitor);};classVisitor{public:virtualvoidvisit(CallNode*no

c++ - Pimpl with unique_ptr : Why do I have to move definition of constructor of interface to ".cpp"?

只要我不将构造函数(B)的定义移动到标题B.h中,代码就可以工作。B.hclassImp;//imp;B();//B.cpp#include"B.h"#include"Imp.h"B::B(){}~B::B(){}Imp.hclassImp{};Main.cpp(编译我)#include"B.h"Error:deletionofpointertoincompletetypeError:useofundefinedtype'Imp'C2027我能以某种方式理解必须将析构函数移动到.cpp,因为可能会调用Imp的解构:-deletepointer-of-Imp;//somethinglik

c++ - 有哪些简单的方法可以用 COM 接口(interface)包装基于 C++ 的对象模型

我有一个预先存在的c++对象模型,它表示应用程序的业务层层。我希望能够将对象模型暴露给用其他语言编写的应用程序,即vbscript、VB、javascript等。我相信这样做的最好方法是用COM层包装业务对象。有什么快速有效的方法可以做到这一点。任何建议,实用的“如何”文档的链接将不胜感激。因为我正在为此开始赏金,这里有一些针对潜在赏金猎人的额外指南:-1)我决定采用ATL方法2)我现在正在专门寻找有关包装预先存在的c++对象模型的非常好的“如何和快速”文档的链接,以使其可用于诸如javascript之类的脚本语言3)一些带有小的工作示例的东西向我展示了哪些代码需要添加到哪些文件中,例