Which uses less memory?
a)
struct astruct
{
int x;
float y;
int v;
};
b)
union aunion
{
int x;
float v;
};
c)
char array[10];
Answer Posted / jaroosh
And the explanation for the above answer is :
union has the size of the biggest type of its member, so
here its size is 4, while structs size is 4 + 4 + 4 = 16,
and arrays size is 1 * 10 = 10.
| Is This Answer Correct ? | 10 Yes | 0 No |
Post New Answer View All Answers
How are virtual functions implemented in c++?
Why do we use vector in c++?
Explain rtti.
What is the array and initializing arrays in c++?
What is a storage class? Mention the storage classes in c++.
What are namespaces in c++?
Write a Program for read a line from file from location N1 to N2 using command line arguments. Eg:exe 10 20 a.c
List down the guideline that should be followed while using friend function.
Can notepad ++ run c++?
Write a function that swaps the values of two integers, using int* as the argument type?
What is isdigit c++?
Explain dangling pointer.
Why namespace is used in c++?
Why do you use the namespace feature?
Explain how we implement exception handling in c++?