<p>In C++, is it safe to extend scope via a reference?</p>

<p>In code, what I mean is: </p>

<pre><code>MyCLass&amp; function badIdea()
{
    MyClass obj1;
    ...
    return obj1;
}
</code></pre>

Please clarify what you do mean.
Assuming you intend to do this:
```
```
int * p = NULL;
{
  int y = 22;
  p = &y;
}
*p = 77; // BOOM!
```
```
Then no, absolutely not, scope does not get extended by having a reference.
You may want to look at smart pointers, e.g. from boost libraries:
clickety