What does mean "struct foo f = {0};"?
-
struct foo
{
int i;
};foo f = {0}; // <- What does this mean?
-
struct foo
{
int i;
};foo f = {0}; // <- What does this mean?
what about initialize the struct ?
Watched code never compiles.
-
struct foo
{
int i;
};foo f = {0}; // <- What does this mean?
-
struct foo
{
int i;
};foo f = {0}; // <- What does this mean?
In Visual Studio this will initialize the structure to all zeros similar to
ZeroMemory(&f, sizof(struct foo));
«_Superman_»
I love work. It gives me something to do between weekends. -
ant-damage wrote:
foo f = {0}; // <- What does this mean?
creating an instance of structure foo(in the name of "f") with i's value zero.
-- "Programming is an art that fights back!"
And if we have
struct point
{
float x;
float y;
float z;
};struct face
{
point a;
point b;
point c;
};face f = {0}; // <- This will initialize to zero the struct, and its elements?
-
And if we have
struct point
{
float x;
float y;
float z;
};struct face
{
point a;
point b;
point c;
};face f = {0}; // <- This will initialize to zero the struct, and its elements?
ant-damage wrote:
struct face{ point a; point b; point c;};face f = {0}; // <- This will initialize to zero the struct, and its elements?
Yes, (I guess point is of type similar to CPoint containing x & y), above code will initialize x & y values of a, b & c to zeroes.
-- "Programming is an art that fights back!"
-
ant-damage wrote:
struct face{ point a; point b; point c;};face f = {0}; // <- This will initialize to zero the struct, and its elements?
Yes, (I guess point is of type similar to CPoint containing x & y), above code will initialize x & y values of a, b & c to zeroes.
-- "Programming is an art that fights back!"
That is exactly what I wanted to know. Thanks.
-
That is exactly what I wanted to know. Thanks.
-
In Visual Studio this will initialize the structure to all zeros similar to
ZeroMemory(&f, sizof(struct foo));
«_Superman_»
I love work. It gives me something to do between weekends.... the code of
... = {0};
may be much faster (than the code ofZeroMemory(..)
) :)virtual void BeHappy() = 0;