#include <iostream>
using namespace std;

class A {
public:
	A() {}
	~A() { cout << "A Destructor"; }
};

template<typename Type>
class TemplateTest {
protected:
	Type* start;
	Type* end;
	Type* iter;
public:
	void Generate(unsigned int count) {
		start = new Type[count];
		end = start + count;
		iter = start;
	}
	void DestroyAll() {
		for(; start < end; ++start) {
			(*start).~Type();
		}
	}
	void Push(Type val) {
		*iter = val;
		iter++;
	}
};

int main() {
	cout << "Non-pointer test" << endl;
	TemplateTest<A> npt;
	npt.Generate(5);
	npt.DestroyAll();
	
	cout << "\nPointer test";
	TemplateTest<A*> pt;
	pt.Generate(5);
	pt.Push(new A());
	pt.DestroyAll();
	
	return 0;
}