2 youthtown YouthTown 于 2014.10.18 17:05 提问

读一段c++源代码,里面的array类里面的输出函数,看不懂什么意思。

template //看不懂
void array::print(void)
{
if(dim_3==1)
{
int i,j,k;
bool threeD = (dim_2==1?false:true);
for (k = 0; k< dim_2; k++)
{
if (threeD)
cout<<endl<<"ans(:,:,"<<k+1<<") = "<<endl;
for(i=0; i<dim_0; i++)
{
for(j=0; j<dim_1; j++)
{

              if((*this)(i,j,k)*(*this)(i,j,k)<1e-12)
                {
                  cout << " 0 ";
                }
              else
                {
                  cout << " " << (*this)(i,j,k) << " ";
                }
            }

          cout << endl;
        }
      if (threeD)
        cout<<endl;
    }
}

else
{
cout << "ERROR: Can only print an array of dimension three or less ...." << endl;
}
}

Csdn user default icon
上传中...
上传图片
插入图片