星期四, 九月 09, 2010

C++ initialization problem

A constructor like:
xVec(int a):n(a),v(new double[n]){}
is error prone, as the initialization is done randomly, the safest way is:
  xVec(int a):n(a),v(new double[a]){}
as variable 'a' always exist when declaring.

没有评论: