It might be worth considering using two different classes for this:
struct basic_tree {
virtual ~basic_tree();
};
// Warning: incomplete -- at the very least, this almost certainly needs to
// define its own assignment operator and copy ctor (aka the rule of three),
// or else declare them private to prevent them (or use `=delete` in C++11).
//
class owning_tree : public basic_tree {
int *A;
public:
owning_tree(int n) : A(new int[n]) {}
~owning_tree() { delete [] A; }
};
class non_owning_tree : public basic_tree {
int *A;
public:
non_owning_tree(int *data) : A(data) {}
};
This has both good and bad points. On one hand, once you've created an object of the right type, everything else gets handled automatically by the type system. On the other hand, it means you have to specify the correct type at construction time, not just pass the right type of parameter. It also means most tree operations need to use a pointer or reference to a basic_tree, rather than being able to use tree objects directly. Depending on the situation, that could vary from no problem at all (e.g., if a tree will often be large enough that you're normally going to pass by reference anyway) to a massive problem, such as adding a lot of extra code to sort out the right type at creation time.