How would you change the same member of many objects of the same class (or structure if possible)?

struct point
{
    float x, y, z;
}

point a, b, c;

a.x += 20;  //
b.x += 20;  // now how would i do this in one statement?
c.x += 20;  //

I don't see how inheritance or polymorphism would apply, and as far as I know they don't work with structures anyway, and I really have no need of classes. So how would I change all point::x members universally regardless of how many or what objects use it?

Well I need each x member to have different instances, like this:

struct point
{
    float x, y, z;
}

point a, b, c;

a.x = 10;
b.x = -50;
c.x = 2000.3258;

a.x += 20;  //
b.x += 20;  // now how would i do this in one statement?
c.x += 20;  //

and yet be able to modify them all, even if there were hundreds of instances of point.

Well I need each x member to have different instances, like this:

struct point
{
    float x, y, z;
}
 
point a, b, c;
 
a.x = 10;
b.x = -50;
c.x = 2000.3258;
 
a.x += 20;  //
b.x += 20;  // now how would i do this in one statement?
c.x += 20;  //

and yet be able to modify them all, even if there were hundreds of instances of point.

How about creating an array of points, then using a loop to traverse each element of the array?

Okay, I'll use a multidimesional array to store the 'objects'. I just thought it would be helpful if I could name them different things and use the default copy constructor/copy assignment constructor, like b = a; or point top (c); . Don't you think such a member-modifying feature should be added to C++? It would be awesome.
:)

This article has been dead for over six months. Start a new discussion instead.