A vector<X,A>::get_allocator() const;
#include <vector>
#include <iostream> #include <vector> int main() { using namespace std; // Create a vector instance vector<int> qV; vector<int>::allocator_type qAlloc = qV.get_allocator(); // Use the allocator to allocate an array of three ints allocator<int>::pointer qPtr = qAlloc.allocate(3); qPtr[0] = 8; qPtr[1] = 4; qPtr[2] = 2; // Output the three ints in the allocate array for (int iIndex = 0; iIndex < 3; ++iIndex) { cout << qPtr[iIndex] << " "; } cout << endl; // Deallocate the array qAlloc.destroy(qPtr); // Keep the window open cin.get(); return 0; }
© 20072025 XoaX.net LLC. All rights reserved.