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 static class data?
Which operations are permitted on pointers?
What is the difference between the functions rand(), random(), srand() and randomize()?
What is flush () in c++?
What are the various arithmetic operators in c++?
What is type of 'this' pointer?
What header file is needed for exit(); a) stdlib.h b) conio.h c) dos.h
What is function overloading in C++?
What is the real purpose of class – to export data?
Do you know what are static and dynamic type checking?
How much do c++ programmers make?
How c functions prevents rework and therefore saves the programers time as wel as length of the code ?
What is atoi?
If you push the numbers (in order) 1, 3, and 5 onto a stack, which pops out first a) 1 b) 5 c) 3
Can class objects be passed as function arguments?