C++ Programming - OOPS Concepts - Discussion
Discussion Forum : OOPS Concepts - General Questions (Q.No. 21)
21.
Which of the following is correct about class and structure?
Discussion:
23 comments Page 2 of 3.
Ashutosh Ghimire said:
1 decade ago
@Ravi Mayank.
You are mixing up C and C++. C is not an OOP.
You are mixing up C and C++. C is not an OOP.
Vaishali Gurram said:
1 decade ago
Structure members are public by default and hence we can access it anywhere in the program through structure variable. Whereas class members are private to provide security to data members and member functions.
Vivek Singh said:
1 decade ago
The members of a struct are public by default, while in class, they default to private.
But the more technical:
Structure is an open container (i.e. Publicly open for everyone) that violate Encapsulation. That's why the Class is invented in c++.
But the more technical:
Structure is an open container (i.e. Publicly open for everyone) that violate Encapsulation. That's why the Class is invented in c++.
Vikas Pareek said:
10 years ago
Option A is correct as well because this is the difference between Classes and structures that structures cannot have member functions while classes can.
Raghava said:
10 years ago
Can structures in C, have member functions?
Sumit said:
9 years ago
No, structure can't have a member functions.
The fundamental difference between C and C++. C++ supports classes (and in C++ a struct is a special case of a class), and C does not.
The fundamental difference between C and C++. C++ supports classes (and in C++ a struct is a special case of a class), and C does not.
Bhavin panchal said:
8 years ago
Option A also true.
Priya said:
8 years ago
Anybody can explain option A, in detailed form?
BADAL MAITY said:
8 years ago
The option A is correct.
Manpreet said:
8 years ago
I think A is also the correct answer.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers