当前在线人数17593
首页 - 分类讨论区 - 电脑网络 - 葵花宝典版 -阅读文章
未名交友
[更多]
[更多]
文章阅读:Re: VC里面的stl支持是不是很弱?
[同主题阅读] [版面: 葵花宝典] [作者:observer] , 2004年07月14日16:43:40
observer
进入未名形象秀
我的博客
[上篇] [下篇] [同主题上篇] [同主题下篇]

发信人: observer (笑看人生), 信区: Programming
标  题: Re: VC里面的stl支持是不是很弱?
发信站: Unknown Space - 未名空间 (Wed Jul 14 17:03:36 2004), 转信

Thanks for replying.

I checked the books and the right way is:

template <class T>
PointGeneric3D<T>::PointGeneric3D(const T xx, const T yy, const T zz)
: z(zz), PointGeneric<T>(xx, yy)
{
}

I know virtual functions, just don't remember so many details as you do.

Thank you all for clear this confusion for me.


【 在 thrust (哼哼的多隆猪) 的大作中提到: 】
: 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
: : PointGeneric<T>().
: 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: 141.210.]

[上篇] [下篇] [同主题上篇] [同主题下篇]
[转寄] [转贴] [回信给作者] [修改文章] [删除文章] [同主题阅读] [从此处展开] [返回版面] [快速返回] [收藏] [举报]
 
回复文章
标题:
内 容:

未名交友
将您的链接放在这儿

友情链接


 

Site Map - Contact Us - Terms and Conditions - Privacy Policy

版权所有,未名空间(mitbbs.com),since 1996