Home » U++ Library support » U++ Widgets - General questions or Mixed problems » why no 'Ctrl* Ctrl::Clone() const = 0' (virtual constructor)
Re: why no 'Ctrl* Ctrl::Clone() const = 0' (virtual constructor) [message #28381 is a reply to message #28377] |
Tue, 31 August 2010 13:45 |
|
kohait00
Messages: 939 Registered: July 2009 Location: Germany
|
Experienced Contributor |
|
|
the new Ctrl would go to an Array<Ctrl>::Add(Ctrl* newt);
so it wont disappear..
this clone feature is quite well known from C# and i learned to like it..it enables you to manage your object containers from 'bottom', kind of flexibility.
something like the following woule be a layer to use maybe, but includes changes as well
template<class T>
class Clonable
{
public:
virtual T* Clone() const { return DeepCopyNew<T>(*(T*)this); }
virtual T* PartialClone() const { return new T(); }
};
class ValueC
: public Value, public Clonable<ValueC>
{
public:
ValueC() {}
ValueC(const Value& v) : Value(v) {}
};
template<class T>
T* Clone(const T& c) { return DeepCopyNew(c); }
template<class T>
T* PartialClone(const T&) { return new T(); }
[Updated on: Tue, 31 August 2010 13:47] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Mon May 13 01:14:46 CEST 2024
Total time taken to generate the page: 0.02129 seconds
|