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 is the best way to take screenshots of a window with c++ in windows?
What is a constructor in c++ with example?
Describe the role of the c++ in the tradeoff of safety vs. Usability?
What is a map in c++?
Will the following program execute?
If dog is a friend of boy, is boy a friend of dog?
Why is it called c++?
Explain terminate() and unexpected() function?
What is the difference between containment and delegation?
What are multiple inheritances (virtual inheritance)?
What is polymorphism & list its types in c++?
What does it mean to declare a member variable as static?
Can a constructor return a value?
What is bubble sort c++?
Explain data encapsulation?