Question:
What is the difference between class and structure?
Answer:
1:By default,the members of structures are public while that for class is private<br><br>2: strutures doesn't provide something like data hiding which is provided by the classes<br><br>3: structures contains only data while class bind both data and member functions<br> Source: CoolInterview.com
The Differences between Structure and Classes are as follows:<br> 1. By default structure are public while a class is private.<br> 2. A Class can be inherited while a structure can not be inherited.<br>NOTE:- 1.Strutures provide data hiding which is provided by the classes, by public and private.<br> 2.Structures contains both data as well as member functions. Source: CoolInterview.com
Answered by: Himanshu Shrivansh` | Date:
| Contact Himanshu Shrivansh`
A structure can also be inherited just like a class Source: CoolInterview.com
| Contact
1.Structer and class both provide data hiding by using public and private and protected.<br>2.by default data members in the structer are public.<br>3. structer can not contain pure virtual and virtual function.<br>4. inheritance not allowed in the struct.<br><br><br> Source: CoolInterview.com
Answered by: Abhishek Kesharwani | Date: 5/8/2010
| Contact Abhishek Kesharwani
By default all the members of the class are private where as in structure all the members are public
Regards, Nicku Source: CoolInterview.com
Answered by: nicku | Date: 8/16/2010
| Contact nicku
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|