Dangling pointer
<p>Does this piece of code lead to dangling pointer. My guess is no.</p>

<pre><code>class Sample
{
public:
int *ptr;
Sample(int i)
{
ptr = new int(i);
}

~Sample()
{
delete ptr;
}
void PrintVal()
{
cout &lt;&lt; "The value is " &lt;&lt; *ptr;
}
};

void SomeFunc(Sample x)
{
cout &lt;&lt; "Say i am in someFunc " &lt;&lt; endl;
}

int main()
{
Sample s1 = 10;
SomeFunc(s1);
s1.PrintVal();
}
</code></pre>
