我有这段代码,它将 8 个元素的数组分配给一个指向j
自定义结构 ( Input_Leo
) 实例的指针。
在CFNN.cpp中:
{
double tx_tech_variable_vec[8] = { 0 }; //I need this re-initialization // code testing: variable rates on the initial premium payment of FIB/Invest Products with a time-variable garantueed interest rate */*/
tx_tech_variable_vec[0] = 3.0; // it does not help to declare it in CFNN.H, as part of the InputLeo structure, you have to do it here before also
tx_tech_variable_vec[1] = 1.5;
DATE tx_tech_variable_dates_vec[8] = { 0, 0 }; // initialization
tx_tech_variable_dates_vec[0] = { 2026, 07 };
tx_tech_variable_dates_vec[1] = { 2032, 07 }; // assignment
j->tx_tech_variable_vec = tx_tech_variable_vec; // overwrites everything (so for each contract (subcontract?), a new vector is written to j)
j->tx_tech_variable_dates_vec = tx_tech_variable_dates_vec; // overwrites everything (so for each contract (subcontract?), a new vector is written to j)
}
在 CFNN.H 中:
struct Input_Leo /* input for Leo */
{
DATE calculation_date = { 2000, 0 }; // Calculation date (used for RADP as date of the payment of unexpected premium)
DATE cohortmonthly = { 2000, 0 }; //date payement prime conclusion (used in total business mode for the month of payment of yearly premiums, to know if we reached 12 months of historic of unex premiums)
int lnumcon = 0; // Contract number
int cregfsc = 0;
and so on...
double* tx_tech = nullptr; // pointer on Tx_res_LEO to allow for dynamic memory allocation, depending on the number of subcontracts
double tx_tech_variable_vec[8] = {0};
DATE tx_tech_variable_dates_vec[8] = {0, 0}; /* code testing not sure I need to add it here */
};
我收到此错误:
Line Severity Code Description Project File Suppression State
4681 Error C3863 array type 'double [8]' is not assignable CF_2012_V7 C:\Users\U03630\Source\Repos\ctool\Main\code\CFNN.CPP
Line Severity Code Description Project File Suppression State
4682 Error C3863 array type 'DATE [8]' is not assignable CF_2012_V7 C:\Users\U03630\Source\Repos\ctool\Main\code\CFNN.CPP
我在这里做错了什么?我应该自己明确指定数组的长度吗?
DATE
此外,这些元素应与( )兼容div_t type
。std::array
如果我与or一起工作,情况还会如此吗std::vector
?
旁注:
是的,我知道这不是最好的方法,但是,是的,我使用的程序中有 90000 行代码,它们已经使用了这种DATE
结构和这种数组方式来处理事物。因此,只是添加几行代码,我不会引入向量或摆脱宏或发明另一种DATE
与其余(确实非常可疑)代码不兼容的类型。