# Updating argument for a matrix every frame

Question is how to properly use continuously changing argument every frame. I have Class Shape, which have children Box, Sphere, etc..., I'll follow with Box example. Each of children have

class Box:
{
float alpha = 0.0f;
Matrix = Identity;

GetTransform() //used in Constant Buffer class which binds it to the pipeline.
{ return Matrix; }

SetMatrix(in_Matrix)
{ Matrix = in_Matrix; }

Update(float t)
{ alpha = t; }
}
Class App:
{
//some multiplications, problem if I want continuous change, rotation for example, which will look
like
NewMatrix = RotationX(alpha) * (someMatrix //if needed);

doFrame() //this is being called every frame
{
Box[i]->BindAndDrawIndexed();
Box[i]->SetMatrix(NewMatrix);
Box[i]->Update(//some continuously changing float, like timer);
}
}


My problem it won't work with rotation (or witn any matrix for which I want some continuously changing argument) if I create NewMatrix outside of doFrame() function. If I create NewMatrix inside of DoFrame(), it'll look like

Box[i]->SetMatrix(RotationX(Shape[i]->alpha) * AnotherOptionalMatrix);
Box[i]->Update(timer);


And that works just fine, but somewhat inconvenient, and it would mean that I have to create a new matrix every frame. When I tried to create NewMatrix outside of doFrame(), I made alpha in Box static, so it exists before a Box is created, but then Update won't update it. Or rather it does update it(I can see in debugger), but I think it updates some other copy of alpha, while NewMatrix uses original Box::alpha. How can I make Update work with static variable, or maybe some other way to update a float?

Another solution it just do only Rotation inside of doFrame(), while creating any other matrix outside, then multiply inside of doFrame(), but it would be nice to have all in one.