I
Immortal Nephi
I sometimes put static keyword after class definition. Is static
safe to use with iostream classes? I need to place it in the function
body. The string in the function body stays in memory for lifetime
until program terminates.
enum Ereport_Behavior
{
eEnter,
eTrace,
eExit
};
void Trace( const Ereport_Behavior eReport_Behavior,
const string strText )
{
static ostringstream ossText;
if( eReport_Behavior == eEnter )
{
ossText.str( “” );
ossText << “Entering…\n”;
}
else if( eReport_Behavior == eTrace )
ossText << strText;
else if( eReport_Behavior == eExit )
{
ossText << “Exiting…\n\n”;
cout << ossText.str();
}
}
int main()
{
Trace( eEnter, “” );
Trace( eTrace, “Testing Trace()…” );
Trace( eExit, “” );
Return 0;
}
safe to use with iostream classes? I need to place it in the function
body. The string in the function body stays in memory for lifetime
until program terminates.
enum Ereport_Behavior
{
eEnter,
eTrace,
eExit
};
void Trace( const Ereport_Behavior eReport_Behavior,
const string strText )
{
static ostringstream ossText;
if( eReport_Behavior == eEnter )
{
ossText.str( “” );
ossText << “Entering…\n”;
}
else if( eReport_Behavior == eTrace )
ossText << strText;
else if( eReport_Behavior == eExit )
{
ossText << “Exiting…\n\n”;
cout << ossText.str();
}
}
int main()
{
Trace( eEnter, “” );
Trace( eTrace, “Testing Trace()…” );
Trace( eExit, “” );
Return 0;
}