|
ex4-14.cpp - Example 4-14 Static Class objects |
// File: ex4-14.cpp - Static objects
#include <iostream>
using namespace std;
class thing
{
public:
thing()
{
cout << "thing constructor called for " << this << endl;
}
~thing()
{
cout << "thing destructor called for " << this << endl;
}
};
thing& funk()
{
static thing T;
cout << "funk() called: &T=" << &T << endl;
return T;
}
int main()
{
cout << &(funk()) << endl;
cout << &(funk()) << endl;
cout << &(funk()) << endl;
return 0;
}
CIS27: Programming in C++ Instructor: Joe Bentley