W
Wellu =?iso-8859-1?Q?M=E4kinen?=
Hi all,
let's say I have a need to store 4 int values in somekind
of a structure. I have atleast two options:
class A
{
public:
int a, b, c, b;
};
or
struct A
{
int a, b, c, d;
};
I know that when the compiler, in my case gcc 2.9.5,
compiles the class it generates constructor and destructor
automatically which makes the class a bit less efficient
than the struct. Note, that I don't need any getters or
setters. This whole question is totally theoretic.
Is there any advantage using structs e.g. can the compiler
optimize struct better than the class? Is this kind of a
struct same as four independent ints somewhere in the code?
I mean does the struct declaration itself reserve some
memory or could it make the program harder to optimize for
the compiler than just four ints?
Thanks for any ideas,
--
|||
(0-0)
+--------oOO--(_)--OOo----------------------------+
| Wellu Mäkinen www.wellu.0rg |
| |
| No tears please, it's a waste of good suffering |
+-------------------------------------------------+
let's say I have a need to store 4 int values in somekind
of a structure. I have atleast two options:
class A
{
public:
int a, b, c, b;
};
or
struct A
{
int a, b, c, d;
};
I know that when the compiler, in my case gcc 2.9.5,
compiles the class it generates constructor and destructor
automatically which makes the class a bit less efficient
than the struct. Note, that I don't need any getters or
setters. This whole question is totally theoretic.
Is there any advantage using structs e.g. can the compiler
optimize struct better than the class? Is this kind of a
struct same as four independent ints somewhere in the code?
I mean does the struct declaration itself reserve some
memory or could it make the program harder to optimize for
the compiler than just four ints?
Thanks for any ideas,
--
|||
(0-0)
+--------oOO--(_)--OOo----------------------------+
| Wellu Mäkinen www.wellu.0rg |
| |
| No tears please, it's a waste of good suffering |
+-------------------------------------------------+