Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

½Ð°ÝÃö©ó¤@­Ó overloaded operator 'new' ªº°ÝÃD..

0 views
Skip to first unread message

Jye

unread,
Sep 5, 1996, 3:00:00 AM9/5/96
to

==> 在 Lock@cis_nctu (交大四蠢之囉唆硬漢) 的文章中提到:
> 請問各位 OOP 高手:

> d:\stl\defalloc.h(124) : error C2660: 'new' : function does not take
> 2 parameters

請問您有overload new(new_initializer, placement)
這個operator嗎?


> [33;1mtemplate <class T1, class T2>
> inline void construct(T1* p, const T2& value) {
> new (p) T1(value); [34m // 錯誤訊息指到這一行 [33m
> }
> [0m

依您的原意, 寫成 p=new T1(value); 應該就可以了...
不然就得要overload new 這個operator.

根據Stroustrup "THE C++ PROGRAMMING LANGUAGE SECOND EDITION" r.5.3.3:

"allocation-expression:
:: new placement new-type-name new-initializer

... [刪去]

The placement syntax can be used to supply additional arguments.
For example, new T results in a call of operator new(sizeof(T))
and new (2,f) T results in a call operator new (sizeof(T), 2, f)"

請各位前輩指正.
--
* Origin: ★ 交通大學資訊科學系 BBS ★ <bbs.cis.nctu.edu.tw: 140.113.23.3>

0 new messages