R
rhd
Hi,
- C++ class with a private member function.
- Private member function declares a static int locally with an
initial value of 0 .
- A single instance of the class is created.
- The object calls the member function a number of times, each time
the local variable is incremented.
- Eventually the object calling the member function is deleted.
Static int has a non-zero value at time of deletion.
- A new instance of the class is created.
What will be the value of the static int within the member function
when the object is re-created?
- Will it be 0 or the last value it held before the deletion of the
initial object?
If there were multiple instances of the object would this static
variable, within a non-static member function, be shared between all
instances or would all instances receive their own "static" copy?
Note - Using Microsoft Visual Studio C++ for Windows CE.
rhd
- C++ class with a private member function.
- Private member function declares a static int locally with an
initial value of 0 .
- A single instance of the class is created.
- The object calls the member function a number of times, each time
the local variable is incremented.
- Eventually the object calling the member function is deleted.
Static int has a non-zero value at time of deletion.
- A new instance of the class is created.
What will be the value of the static int within the member function
when the object is re-created?
- Will it be 0 or the last value it held before the deletion of the
initial object?
If there were multiple instances of the object would this static
variable, within a non-static member function, be shared between all
instances or would all instances receive their own "static" copy?
Note - Using Microsoft Visual Studio C++ for Windows CE.
rhd