This is an extremely unusual construction. You usually don't want to apply a function to all instances of a class, but to some specific subset of them, which may or may not happen to be all of them. For example, this would be much more common:
1 2 3 4
std::vector<polygon> v;
//...
for (size_t a=0;a<v.size();a++)
//etc.
Anyway, yes. What you want to do can be done with polymorphism. The code that calls the function would look like this:
1 2 3 4
std::vector<polygon *> v;
//...
for (size_t a=0;a<v.size();a++)
v[a]->double_size();
polygon would declare double_size() as a pure virtual function:
1 2 3 4 5
class polygon{
//...
virtualvoid double_size()=0;
//...
};
Now every class that inherits from polygon would have to implement double_size().
Polymorphism has some subtleties I can't cover here. I recommend checking your book on the subject, if you have one.