Re: Future of C++
On 2008-08-07 05:58:27 -0400, Razvan Cojocaru <razvanco@gmx.net> said:
Is it? How does a protected base class destructor solve the following
problem?
class Base {
public:
virtual perform() = 0;
protected:
~Base() {} // non-virtual destructor
};
class Derived : public Base {
public:
Derived() { rh_ = allocate_resource(); }
~Derived() { deallocate_resource(rh_); }
virtual perform() { /* implement me */ }
private:
// we're handling resources, careful with asignment
Derived(const Derived&);
Derived& operator=(const Derived&);
private:
resource_handle_t rh_;
};
int main()
{
std::auto_ptr<Base> pb(new Derived);
Error here: can't access Base::~Base().
--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]