[SOURCE]
int *foo()
{
static int i;
return &i;
}
int *i = foo();
*i = 1;
[/SOURCE]
using static var from function outside the functionbody
Im using a static variable from a funktion outside the funktion.
Is there any danger doing this?
Dangers:
1) Obvious: Don't try and delete the returned value. Return a reference instead to indicate the function owns it.
2) Pernicious: Global data can destroy your design.
1) Obvious: Don't try and delete the returned value. Return a reference instead to indicate the function owns it.
2) Pernicious: Global data can destroy your design.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement