【发布时间】:2019-05-07 19:00:17
【问题描述】:
我想将一个对象静态分配给这些对象中的一组。在下面代码的末尾,CO_m_contractInfo 数组中的所有三个条目 (0,1,2) 都指向 m_contractInfo,其中包含来自第三个合约的信息。希望数组包含第一个、第二个和第三个合约的静态信息。
如何实现静态分配,以便数组包含所有 3 个合同的合同信息?
Private m_contractInfo As IBApi.Contract
Public CO_m_contractInfo() As Contract
ReDim CO_PO_m_contractInfo(0 To 10)
' info from 1st contract loaded into m_contractInfo
CO_m_contractInfo(0) = m_contractInfo
' info from 2nd contract loaded into m_contractInfo
CO_m_contractInfo(1) = m_contractInfo
' info from 3rd contract loaded into m_contractInfo
CO_m_contractInfo(2) = m_contractInfo
' at this point, all three entries (0,1,2) in the CO_m_contractInfo
' array point to m_contractInfo which contains info from 3rd contract
【问题讨论】: