Wednesday, 18 September 2013

Value intialized before main() disappears

Value intialized before main() disappears

Can not understand weird program behavior - hopefully someone can explain.
dummy.h:
#ifndef DUMMY_H
#define DUMMY_H
#include <iostream>
class Dummy
{
int val;
public:
int Init(int new_val)
{
return val = new_val;
}
int Get()
{
return val;
}
Dummy():
val(-1)
{
std::cout << "constructed" << std::endl;
}
~Dummy()
{
std::cout << "deconstructed" << std::endl;
}
};

No comments:

Post a Comment