Skip to content

Instantly share code, notes, and snippets.

@flyingmutant
Created November 6, 2011 16:08
Show Gist options
  • Save flyingmutant/1343084 to your computer and use it in GitHub Desktop.
Save flyingmutant/1343084 to your computer and use it in GitHub Desktop.
#include <boost/scoped_ptr.hpp>
#include <boost/scoped_array.hpp>
class Foo
{
public:
Foo(size_t j): i(new int[j]) {}
virtual ~Foo() {}
private:
boost::scoped_array<int> i;
};
class Bar: public Foo
{
public:
Bar(size_t j): Foo(j), i(new char[j]) {}
private:
boost::scoped_array<char> i;
};
int main()
{
boost::scoped_ptr<Foo> f(new Foo(100));
boost::scoped_ptr<Foo> b(new Bar(200));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment