I believe I have it understod but I just want confirmation. If I have two functions,
function A()
{
const Vector3D vectorA(1.0f);
...
}
function B(float var)
{
const Vector3D vectorB(1.0f + var);
...
}
In the case of function A()
, will vectorA
only be constructed once in the program, no matter how many A()
calls? I believe the compiler implicitly declares it static yes?
But in the case of B()
, vectorB
needs to be reconstructed each function call?
Both functions will create the variables every time they are called. There is no implicit static. Some compilers may choose to optimize but it is not part of the language specification.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With