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 kind of jobs can I get with c++?
Explain this pointer?
What does it mean to declare a member function as static?
Which is not a valid keyword a) public b) protected c) guarded
What is the rule of three?
How do I run c++?
Explain some examples of operator overloading?
What is searching? Explain linear and binary search.
What is the default access level?
What is cout flush?
What is type of 'this' pointer?
Why is c++ called oops?
What is a node class in c++?
Is c++ a low level language?
What is a string example?