Código:
#include<iostream> using namespace std; class A { int n; public: A() { n = 0; } int GetN() { return n; } int SetN(int new_n) { n = new_n; } }; class Vector_A { A** array; int size; public: Vector_A() { array = new A*; size = 0; } int Size() { return size; } void agregar(A *a) { size++; array[size] = a; } void eliminar(int index) { if (index > 0 && index <= size) { for(int i = index; i <= size; i++) { if (i + 1 <= size) { array[i] = array[i + 1]; //array[index + 1] = eliminated; } else { //array[index] = eliminated; } } size--; } } A* ver(int index) { //if (index > 0 && index <= size) { return array[index]; } return array[index]; } void liberar() { delete[] array; } }; void asignar(Vector_A *vector_a) { for(int i = 1; i <= vector_a->Size(); i++) { vector_a->ver(i)->SetN(i * 20); } } void ver(Vector_A *vector_a) { for(int i = 1; i <= vector_a->Size(); i++) { vector_a->ver(i)->SetN(i * 20); cout << i << ": " << vector_a->ver(i)->GetN() << endl; } } int main() { Vector_A vector_a; A a, b, c; vector_a.agregar(&a); vector_a.agregar(&b); vector_a.agregar(&c); asignar(&vector_a); ver(&vector_a); vector_a.eliminar(1); ver(&vector_a); cout << "3: " << vector_a.ver(3)->GetN() << endl; vector_a.liberar(); system("PAUSE"); return 0; }