See my code below:
class A
{
public:
A()
{
i = 0;
if(pt != NULL)
{
std::cout << "why" << std::endl;
}
}
A(bool flag)
{
i = 0;
pt = new B(3.14);
}
private:
class B
{
public:
B(double in) : j(in) {}
private:
double j;
};
private:
int i;
B *pt;
};
int main(int argc, char *argv[])
{
A obj; // place1
int *p;
if(p != NULL)
{
std::cout << "test2" << std::endl;
}
return 0;
}
In this piece of code, I wonder to know if pt
will be initialized @place1
.
The other question is that if I delete the definition of obj
, test2
will print, if not, then why?