I am using an array in a simple logic simulator program and I want to switch to using a vector to learn it but the reference I am using \"OOP in C++ by Lafore\" doesn\'t hav
You're half-way there:
std::vector G;
G.push_back(new ANDgate);
G.push_back(new ORgate);
for(unsigned i=0;iRun();
}
Of course, this way you need to take care to ensure that your objects are deleted. I'd use a vector of a smart pointer type such as boost::shared_ptr to manage that for you. You could just store the address of local objects (e.g. G.push_back(&a)), but then you need to ensure that the pointers are not referenced after the local objects have been destroyed.