|
Boost : |
From: James Porter (porterj_at_[hidden])
Date: 2008-04-16 17:03:21
On Tue, Apr 15, 2008 at 5:38 AM, Emre Turkay <emreturkay_at_[hidden]> wrote:
> Hi folks,
>
> In the example below, while (1) is compiling fine, (2) causes compiler error
> in linux gcc 4.1.3.
> I certainly don't want to copy the member variable of the object in copy
> constructor, and I need T2.
> How can I handle it?
>
[snip]
> B(const B<T>& b) { } // (1)
> template <typename T2> B(const B<T2>& b) { } // (2)
Without (1), you'll be using the (implicit) default copy constructor,
which takes precedence over (2) and will attempt to copy A. You need
both copy constructors for this.
- Jim
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk