__interface

__interface

Visual Studio 2015

在原版语言设计中,一个接口类型是用关键字 __interface指明的。在修订版语言中,它被 interface class替代。

Microsoft Specific**

A Visual C++ interface can be defined as follows:

  • Can inherit from zero or more base interfaces.

  • Cannot inherit from a base class.

  • Can only contain public, pure virtual methods.

  • Cannot contain constructors, destructors, or operators.

  • Cannot contain static methods.

  • Cannot contain data members; properties are allowed.

 

Syntax

  
 modifier  
  __interface interface-name {interface-definition};  

 

Remarks

A C++ class or struct could be implemented with these rules, but __interface enforces them.

For example, the following is a sample interface definition:

 __interface IMyInterface {  
    HRESULT CommitX();  
    HRESULT get_X(BSTR* pbstrName);  
 };  

For information on managed interfaces, see interface class .

Notice that you do not have to explicitly indicate that the CommitX and get_X functions are pure virtual. An equivalent declaration for the first function would be:

 virtual HRESULT CommitX() = 0;  

__interface implies the novtable __declspec modifier.

 

Example

The following sample shows how to use properties declared in an interface.

 // deriv_interface.cpp  
 #define _ATL_ATTRIBUTES 1  
 #include <atlbase.h>  
 #include <atlcom.h>  
 #include <string.h>  
 #include <comdef.h>  
 #include <stdio.h>  
  
 [module(name="test")];  
  
 [ object, uuid("00000000-0000-0000-0000-000000000001"), library_block ]  
 __interface IFace {  
    [ id(0) ] int int_data;  
    [ id(5) ] BSTR bstr_data;  
 };  
  
 [ coclass, uuid("00000000-0000-0000-0000-000000000002") ]  
 class MyClass : public IFace {  
 private:  
     int m_i;  
     BSTR m_bstr;   
  
 public:  
     MyClass()  
     {  
         m_i = 0;  
         m_bstr = 0;  
     }  
  
     ~MyClass()  
     {  
         if (m_bstr)   
             ::SysFreeString(m_bstr);  
     }  
  
     int get_int_data()  
     {  
         return m_i;  
     }  
  
     void put_int_data(int _i)   
     {  
         m_i = _i;  
     }  
  
     BSTR get_bstr_data()  
     {   
         BSTR bstr = ::SysAllocString(m_bstr);  
         return bstr;   
     }  
  
     void put_bstr_data(BSTR bstr)   
     {   
         if (m_bstr)   
             ::SysFreeString(m_bstr);  
         m_bstr = ::SysAllocString(bstr);  
     }  
 };  
  
 int main()  
 {  
     _bstr_t bstr("Testing");  
     CoInitialize(NULL);  
     CComObject<MyClass>* p;  
     CComObject<MyClass>::CreateInstance(&p);  
     p->int_data = 100;  
     printf_s("p->int_data = %d\n", p->int_data);                
     p->bstr_data = bstr;  
     printf_s("bstr_data = %S\n", p->bstr_data);  
 }  

Output

 p->int_data = 100  
 bstr_data = Testing  
POSTING_INTERFACE_CLEARING是一个函数,用于进行标准清账操作。它封装了BDC录屏的功能。\[3\]在使用该函数时,如果传入参数ITEM,则必须传入公司代码、记账码和科目。根据你提供的引用内容,你的问题是关于批量创建清账凭证时参照码3的问题。你希望每个参照码3对应一张凭证,但实际上清账凭证创建成功后,参照码3一直沿用了模板中的第一个值。你进行了排查并确认了传参数据的正确性,并清空了相应的内表。然后你尝试使用了free memory来清空ABAP内存变量,并成功解决了问题。然而,你想知道使用free memory会有什么影响。 #### 引用[.reference_title] - *1* [SAP-ABAP-清账函数BAPI使用POSTING_INTERFACE_CLEARING,应付暂估外币清账程序](https://blog.csdn.net/Qunending/article/details/124666847)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* *3* [清账函数POSTING_INTERFACE_CLEARING的应用](https://blog.csdn.net/wangshaoqiang022/article/details/90234375)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值