Mood:

Topic: C++
class MyClass
{
public:
MyClass()
{
cout << "Previous value: " << m_nNum << endl;
m_nNum = 20;
}
private:
int m_nNum;
};
void main()
{
// Constructor invoked once here
MyClass mc;
// Now we are going to invoke once more
::new(( void* )&mc) MyClass;
// First time printed number will be garbage, second time number will be 20
}
Posted by Nibu babu thomas
at 3:26 PM
Updated: Monday, 21 May 2007 11:22 AM