Answer to Question #8440 in C++ for gina

Question #8440
what's the difference between the following functions?

Void init1 ()
{
Static int yrs = 1;

Cout << “The value of yrs is ” << yrs << endl;
Yrs = yrs + 2;

return;
}




Void init2 ()
{
Static int yrs;

Yrs = 1;
Cout << “The value of yrs is ” << yrs << endl;
Yrs = yrs + 2;

return;
}
1
Expert's answer
2012-04-24T07:17:05-0400
The only difference between the following functions is that the first function init1 assigns static variable yrs simultaneously with its initialization and the second one assigns it after initialisation. There are no functional differences here.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS