answersLogoWhite

0

It's not clear what you mean by "call 2 or more objects". Object's aren't "called", they are instantiated. Once instantiated you may "call" (invoke) the member methods associated with those objects, or invoke functions that operate upon those objects. To invoke the same member method on 2 or more objects, simply place those objects in a vector (by reference), then iterate over the vector:

void f (std::vector<my_object*> objects) {

for (auto foo : objects) foo->bar(); // invoke the bar method for each foo object in objects

}

User Avatar

Wiki User

8y ago

What else can I help you with?

Related Questions