> > Also, I would suggest that all classes be made assignable such
> > that memory management is simplified. There is no reason that the
> > user of this library has to fiddle with new and delete.
>
> Could you elaborate on this.
Every class should define these methods:
class Foo {
public:
// Default constructor
Foo();
// Copy constructor
Foo(Foo const & f);
// Assignment operator
Foo & operator=(Foo const & f);
};
Then you can do:
Foo a;
Foo b;
a = b;
Foo c(b);
b = c;
and not worry about memory management.
The only thing to watch out for is assignment to yourself:
a = a;
should work.
If a class is assignable, you can do stuff like this:
vector<Foo> foos;
vector<Foo> foos2;
foos2 = foos;
and it will automatically work.
Similar for stuff like
struct Bar {
Foo foo1;
Foo foo2;
};
Bar a;
Bar b;
a = b;
a.foo1 = b.foo2;
etc.
I.e. if a class is assignable, it behaves much like POD, plain old data.
Greets,
Asger