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.
.
Showing posts with label Difference. Show all posts
Showing posts with label Difference. Show all posts
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.
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.