42 lines
363 B
C++
42 lines
363 B
C++
#include <iostream>
|
|
|
|
class a
|
|
{
|
|
public:
|
|
a()
|
|
{
|
|
std::cout << "construction" << std::endl;
|
|
}
|
|
~a()
|
|
{
|
|
std::cout << "destruction" << std::endl;
|
|
}
|
|
};
|
|
|
|
class guard
|
|
{
|
|
public:
|
|
a _a;
|
|
a* operator & ()
|
|
{
|
|
return &_a;
|
|
}
|
|
};
|
|
|
|
guard f()
|
|
{
|
|
return guard();
|
|
}
|
|
|
|
void g ( a* p )
|
|
{
|
|
std::cout << "working with a" << std::endl;
|
|
}
|
|
|
|
int main()
|
|
{
|
|
g( &f() );
|
|
|
|
return 0;
|
|
}
|