What are the differences between a struct and a class in
C++?
Answer Posted / shivani
In Class Members are private by default.
In Structure Member are public by default.
structures are value typed where as classes are refernce
typed
Class can be inherited But Structure can't be inherited
In structures we cannot initilase the variable during the
declaration while in classes we can.
Structure s does not support polymorphism while class does
Structure can be declared without a tag at the first time,
but not in case of class.
e.g. struct { variables; }(struct variable list); [It would
not raise any error while comlitation]
class { access specifier: variable list; access specifier:
vari....
}; [it will cause an error while compilation]
Is This Answer Correct ? | 3 Yes | 6 No |
Post New Answer View All Answers
What does catch(…) mean?
Explain register storage specifier.
Explain abstraction.
Why is c++ not purely object oriented?
Is c++ a float?
What is stream and its types in c++?
Explain how would you handle a situation where you cannot call the destructor of a local explicitly?
Can non graphic characters be used and processed in C++?
What is java and c++?
What is singleton class in c++?
What is the difference between structure and class?
How can you quickly find the number of elements stored in a static array?
What does asterisk mean in c++?
What is the use of 'using' declaration in c++?
What are the advantages of c++ over c?