g*********s 发帖数: 1782 | 1 is the output undefined? how to initialize this array?
const double* pc = new double[10];
cout << (*pc) << endl; |
a***y 发帖数: 2803 | 2 为什么要const? 没见过这么搞的.
【在 g*********s 的大作中提到】 : is the output undefined? how to initialize this array? : const double* pc = new double[10]; : cout << (*pc) << endl;
|
G****A 发帖数: 4160 | 3 Suppose the default value is 0.
there are two ways (as far as I know) to handle that:
1. const double* pc = new double [SIZE]();
2. std::vector vec(SIZE, 0); --if a vector is working for your
case.
【在 g*********s 的大作中提到】 : is the output undefined? how to initialize this array? : const double* pc = new double[10]; : cout << (*pc) << endl;
|
t****t 发帖数: 6806 | 4 as far as i know, the first is not a valid c++ statement.
【在 G****A 的大作中提到】 : Suppose the default value is 0. : there are two ways (as far as I know) to handle that: : 1. const double* pc = new double [SIZE](); : 2. std::vector vec(SIZE, 0); --if a vector is working for your : case.
|
G****A 发帖数: 4160 | |
t****t 发帖数: 6806 | 6 great! i learned something. thanks for pointing it out.
【在 G****A 的大作中提到】 : I learned this trick from the following source: : http://stackoverflow.com/questions/2204176/how-to-initialise-me
|