J
JKop
What's the difference between them?
Take the following:
#include <iostream>
struct Blah
{
int k;
const char* p_b;
std::string c;
};
I used to think that when you did:
Blah poo = Blah();
that all its members got "default initialized", which resulted in:
poo.k == 0
poo.p_b == 0 (null pointer value)
poo.c (Gets the default std::string constructor called with no arguments)
I'm correct in the above, yes? But now I hear that things have changed and
that
Blah poo = Blah();
results in "value intialization"...
So what's "value intialization" and how is it different from "default
initialization"?
-JKop
Take the following:
#include <iostream>
struct Blah
{
int k;
const char* p_b;
std::string c;
};
I used to think that when you did:
Blah poo = Blah();
that all its members got "default initialized", which resulted in:
poo.k == 0
poo.p_b == 0 (null pointer value)
poo.c (Gets the default std::string constructor called with no arguments)
I'm correct in the above, yes? But now I hear that things have changed and
that
Blah poo = Blah();
results in "value intialization"...
So what's "value intialization" and how is it different from "default
initialization"?
-JKop