Reputation: 173
Would a phrase such as Struct* a = new Struct{1,2,3};
be valid?
It compiles and runs just fine, but I'm wondering if there's anything funky going on behind the scenes.
struct Struct {
int a;
int b;
int c;
}
Upvotes: 0
Views: 450
Reputation: 4011
That code will allocate memory for a new Struct
and initialize the members with 1, 2 and 3, and finally put the pointer to that structure into the variable a
. I have no idea whether you call that funky, though.
Upvotes: 1