Wednesday 15 September 2010

c++ - Is there a way to select what members of one instance I want to assign without manually assigning them all -


I think I have class C whose members are x, y, Z, t, u, vi

  c c1, c2; // ... c1.x = c2.x; C1.u = c2.u; C1.v = c2.v;   

Is this code can be randomized so that I can get the x, u, v ?

I can edit: The motivation is that the class which gets updated but some value is not counted again because they remain the same.

The code can not be

However, it is in the assignment operator for your class Can be explained . "=" Surcharge the operator and keep all those functions in your body. Then you just need to do C1 = C2.

Of course, if you do not have semantic assignments, then you can only create a conventional method assign field (console c & amp; other) then just call c1 .AssignSomeFields (c2); .

No comments:

Post a Comment