you may be able to get what you want with dvector x(1,20); // .... use x x.deallocate(); x.allocate(2,45); // use x etc