Re: [Boost-users] [corrected]How to delay the initialisation of a member in a C++ base class until the ctor of derived class is executed?
25 Mar
2009
25 Mar
'09
1:58 p.m.
Date: Wed, 25 Mar 2009 20:13:02 +1100 From: Alex MDC
Since you're passing the size into the derived constructor, why don't you just pass it through to the base constructor?
class base { public: base(size_t array_size):size(array_size) { p_array.reset(new unsigned char[size]); } private: size_t size; boost::shared_array<unsigned char> p_array; };
class derived { public: derived(size_t array_size):base(array_size) { } };
Will that work for you?
Exactly. Thank you.
5709
Age (days ago)
5709
Last active (days ago)
0 comments
1 participants
participants (1)
-
Zhi Tan