Difference:
C Struct :
-> Cannot have member functions.
-> Cannot exhibit polymorphic behaviour.
-> "Struct MyStruct a". "Struct" Keyword required while declaration.
C++ Struct:
-> Can have member functions.
-> Can exhibit polymorphic behaviour.
-> "MyStruct a". "Struct" Keyword not required while declaration.
.
Monday, August 3, 2009
Sunday, August 2, 2009
Difference between Class and Struct in C++ ?
Current post is on difference between Class and Structure in C++ language.
Difference:
Struct:
- By default access is public
Class :
- By default access is private
It means when:
- member variable is declared
- member function is declared
- It is derived
and one does not specific the access specifier, it will get defaulted to mentioned access specifier
Structure Key Points:
- Struct can have member functions.
- Struct can be derived.
- Struct can have polymorphic behavior.
Appreciate your feedback via comments. Thanks.
Saturday, August 1, 2009
Check whether computer is Little Endian / Big Endian ?
Current post is on how to check whether computer is Big Endian or Little Endian.
Endianness refers - the order in which computer stores the bytes.
Little Endian - Stores LSB (Least Significant Byte) in lowest address.
Big Endian - Stores MSB (Most Significant Byte) in highest address.
Answer:
/* Function returns whether the computer system is Little or Big Endian*/bool IsLittleEndian()
{
int TestNumber = 1;
char * ptr;
ptr = (char *) &TestNumber;
return (*ptr); //True if little Endian.
}
Appreciate your feedback via comments. Thanks.
Subscribe to:
Posts (Atom)
Disclaimer:
The above post and all the posts in the blog are derived from facts, information, logical interpretation and logical conclusion of printed and internet materials available to me, perceived and produced by 99 gm brain of mine, which by no means always be accurate, consistent and complete.
All the posts are for personal quick reference only.
If any suggestion, correction, misinterpretation, misconception commented, which will be moderated and deleted if required, to avoid unforeseen issues.
If any trademark / copywrite issue is present, do send in a mail and appropriate tag (logo, name, website link) will be attached to the same.
Additional disclaimer will be attached wherever required in the post.
The above post and all the posts in the blog are derived from facts, information, logical interpretation and logical conclusion of printed and internet materials available to me, perceived and produced by 99 gm brain of mine, which by no means always be accurate, consistent and complete.
All the posts are for personal quick reference only.
If any suggestion, correction, misinterpretation, misconception commented, which will be moderated and deleted if required, to avoid unforeseen issues.
If any trademark / copywrite issue is present, do send in a mail and appropriate tag (logo, name, website link) will be attached to the same.
Additional disclaimer will be attached wherever required in the post.