//: C03:Getmem.cpp // From Thinking in C++, 2nd Edition // Available at http://www.BruceEckel.com // (c) Bruce Eckel 2000 // Copyright notice in Copyright.txt // Test memory function template #include "Getmem.h" #include using namespace std; int main() { int* p = 0; getmem(p, 10); for(int i = 0; i < 10; i++) { cout << p[i] << ' '; p[i] = i; } cout << '\n'; getmem(p, 20); for(int j = 0; j < 20; j++) { cout << p[j] << ' '; p[j] = j; } cout << '\n'; getmem(p, 25); for(int k = 0; k < 25; k++) cout << p[k] << ' '; freemem(p); cout << '\n'; float* f = 0; getmem(f, 3); for(int u = 0; u < 3; u++) { cout << f[u] << ' '; f[u] = u + 3.14159; } cout << '\n'; getmem(f, 6); for(int v = 0; v < 6; v++) cout << f[v] << ' '; freemem(f); } ///:~