topical media & game development
basic-program-solutions-07-Soln7-5.c
? /
basic-program-solutions-07-Soln7-5.c
// Soln7_5.cpp
include <iostream> // For stream input/output
include <cstring>
using std::cout;
using std::endl;
class CTrace
{
public:
CTrace(const char* str);
~CTrace();
private:
char* pstr;
};
CTrace::CTrace(const char* str)
{
size_t len = strlen(str)+1;
pstr = new char[len];
strcpy_s(pstr, len, str);
cout << "Entry: " << pstr << endl;
}
CTrace::~CTrace()
{
cout << "Exit: " << pstr << endl;
delete pstr;
pstr = NULL;
}
int main()
{
CTrace trace("Main routine");
if (3 > 5)
{
CTrace trace1("'if' block");
}
else
{
CTrace trace2("'else' block");
}
return 0;
}
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.