发信人: thrust (哼哼的多隆猪), 信区: Programming
标 题: Re: VC里面的stl支持是不是很弱？
发信站: Unknown Space - 未名空间 (Wed Jul 14 16:27:33 2004), 转信
vptr and vtbl is the basis of the whole virtual function system,
I assume you know it...
【 在 observer (笑看人生) 的大作中提到: 】
: Actually, I want to call ctor of PointGeneric<T>(T xx, T yy) not
I know you wanted to call that! And I thought you know how to call that...
your way of calling base class ctor is INCORRECT and initializer should
be used. And initializer CAN be used to call ctor with parameter, just
write the parameter down, what do you expect... and pptwo already showed
you how to do that.
: I acknowledge it is automatically called when PointGeneric3D<T>() is called.
: But how about PointGeneric<T>(T xx, T yy).
: By the way, my original way of calling ctor worked fine until I do the
it probably looks fine, but it is incorrect, period.
: following change:
: // class PointInt : public PointGeneric3D<short>
: // ...
: // }
: typedef PointGeneric3D<short> PointInt;
: In sum, do you mean, default base class ctor should not be called explicitly in
: default derived class ctor. I agree with that.
: But how about ctor with parameters?
base class ctor with parameter should not be called explicitly, EITHER!
ctors should almost never be called explicitly. (except that you do the
allocation and initialize separately, but that's rarely used.)
※ 来源:．Unknown Space - 未名空间 mitbbs.com．[FROM: 128.205.]