我需要访问此函数之外的数组:
enter code here
// code in a .cc file
void
ldu1::decode_lcw()
{
uint16_t LCW_BITS[] =
{
410, 411, 412, 413, . . . . . . . . .....
};
uint16_t LCW_BITS_SZ = sizeof(LCW_BITS) / sizeof(LCW_BITS[0]);
uint16_t LCW_BITS = extract(frame_body(), LCW_BITS, LCW_BITS_SZ);
uint16_t encoded_lcw = LCW_BITS;
//call the error correction code from another file, lcw_ecc.h
// decoded_lcw is declared protected in
// the .h file corresponding to this .cc file
lcw_ecc(encoded_lcw, decoded_lcw);
}
最后一行,lcw_ecc()从包含的.h文件中调用此函数:
// code in another file, lcw_ecc.h, which holds the
// error correction function definitions
void lcw_ecc(uint16_t encoded_lcw[], uint16_t decoded_lcw[])
{
uint16_t rs_codewords[144] = {0} ;
void decode_hamming( uint16_t encoded_lcw[], uint16_t rs_codewords[] );
void decode_reed_solomon( uint16_t rs_codewords[], uint16_t decoded_lcw[] );
decode_hamming( encoded_lcw, rs_codewords );
decode_reed_solomon( rs_codewords, decoded_lcw );
}
这些函数在终端中作为单例工作,这个代码在我正在编写的程序的lib中编译时没有错误。但是,我不相信它做得对。
我的问题是,假设代码将按预期修改'decoding_lcw',如何在我放在那里的第一个函数之外的.cc文件的其余部分访问修改后的decoding_lcw数组,“ ldu1 :: decode_lcw()“?? 如果它被声明为私有或受保护将声明其他成员函数能够访问不是为了修改它而仅仅是为了检查?我可以把它作为参数传递吗?