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


Please Help Members By Posting Answers For Below Questions

What are the various operations performed on stack?

622


Is c++ platform dependent?

627


What is meant by const_cast?

642


Will this c++ program execute or not?

597


What are guid?

679






What is the function to call to turn an ascii string into a long?

589


What is the hardest coding language to learn?

593


what kind of projects are suitable for c and c++

614


Write my own zero-argument manipulator that should work same as hex?

573


Are c and c++ different?

531


What is #include c++?

563


Is C++ case sensitive a) False b) Depends on implementation c) True

610


Does c++ have a hash table?

533


What information can an exception contain?

660


What are the storage qualifiers?

659