简体   繁体   English

是否可以在C ++中覆盖此虚拟方法?

[英]Is it possible to override this virtual method in C++?

In this program I'm trying to read data from a serial port but the data being read form the port is not in a format I like (comes out in large chunks). 在此程序中,我尝试从串行端口读取数据,但是从端口读取的数据不是我喜欢的格式(大块出现)。 So I want to override how ReadBytes works. 所以我想重写ReadBytes的工作方式。

BSTR buffer_bstr;
hr = pCom->ReadBytes( &buffer_bstr );

So ReadBytes is found in a library header called AComport.h made by the company ActiveXperts. 因此,在ActiveXperts公司制造的名为AComport.h的库头中可以找到ReadBytes。 When I go to the declaration of ReadBytes it is this 当我去读字节的声明是

    virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE ReadBytes( 
        /* [retval][out] */ BSTR *__MIDL__IComPort0001) = 0;

What is this saying? 这是在说什么 I was looking for an implementation of ReadBytes so that I could change things around but all I see is this. 我一直在寻找ReadBytes的实现,以便可以更改周围的事物,但我所看到的只是这个。 What does it mean? 这是什么意思?

That's not a "real" C++ function, but it's a member function on a COM object that is presented as a C++ wrapper. 那不是一个“真正的” C ++函数,而是一个作为C ++包装器呈现的COM对象上的成员函数。 Unless you implement an object that implements the same COM interface, you can't easily override or overload this function. 除非您实现一个实现相同COM接口的对象,否则您不能轻易覆盖或重载此函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM