coearray.h
来自「气体热力性质计算程序」· C头文件 代码 · 共 53 行
H
53 行
/*=========================================================================================
This program is the coefficient array class, the core in the class is a 2-dimensional
pointer. The coefficients used to precise the Cp, and the temperature limit for each data
segment also exists in this class. The 2-dimensional pointer is allocated to a irregular
2-d array, and there is a unsigned int type pointer "_sublen" allocated to a 1-d array giving
the length of each subarray in the 2-d pointer. The temperaure limit of each segment is also
restored in a 1-d array, which is allocated from a double type pointer. But what is different
from the "_sublen" is that there is more one element in this array than the number of segments.
This redundant element is designed prohibiting the over access to this array by the respondant
function.
-----------------------------------------------------------------------------------------*/
#pragma once
#include<iostream>
class coeArray
{
public:
coeArray(unsigned int len=0);
coeArray(const coeArray &des);
~coeArray();
//copy the values in arrays with memory valid checking and freeing
//and then allocate the new memory
virtual inline coeArray &operator=(const coeArray &des);
//allocate the memory for sub array
virtual inline bool SubAlloc(unsigned int index,unsigned int sublen);
//return the address of the indicated sub array by parameter "index"
virtual inline double *operator[](unsigned int index);
//give the length of first dimension of the 2-d array
virtual inline unsigned int Len();
//give the length of sub array in the 2-d array indicated by "index"
virtual inline unsigned int SubLen(unsigned int index);
//give the reference to the temperature limit of the segment indicated
//by "index"
virtual inline double &Tl(unsigned int index);
private:
//copy the values in arrays without memory valid checking and freeing
//only allocating new memory
virtual inline void CopyArray(const coeArray &des);
double **A; //data used to precise Cp under 1 atm
double *_Tl; //the temperature limit of each data segment
unsigned int _len; //the length of the first dimension of the 2-d array
unsigned int *_sublen; //allocated to restore the sub array length
};
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?