C++ Programming - OOPS Concepts - Discussion

Discussion :: OOPS Concepts - General Questions (Q.No.52)

52. 

Which of the following statements is correct in C++?

[A]. Classes cannot have data as protected members.
[B]. Structures can have functions as members.
[C]. Class members are public by default.
[D]. Structure members are private by default.

Answer: Option B

Explanation:

No answer description available for this question.

Chinna said: (Dec 9, 2012)  
Structures can have functions as members in C++.

Then What about structures in C?

Dipjoyti said: (Jul 9, 2013)  
Class members are public by default.

Structure members are private by default. Is that are correct. Explain?

Sandesh said: (Jul 24, 2013)  
Class members are private by default in c++.

Rasool said: (Aug 7, 2013)  
Class members are private by default.
Structure members are public by default.

Classes can have data as protected members.
Structures can have functions as members.

Abc said: (Aug 23, 2013)  
If we don't provide any accessor in class members, it will be private?

Ghost In Oops said: (Oct 22, 2013)  
Class members are always public by default hence answer is option [C].

Shubham Barnwal said: (Aug 2, 2014)  
B is incorrect answer.

Structure can't have function as a member.

Gopal said: (Aug 18, 2014)  
How can structures have functions as members?

Akash said: (Jan 28, 2015)  
Can some one give me example of such struct?

Sahana said: (Feb 26, 2015)  
Why structures cannot have functions as members? Isn't it that the structures can have both data members and functions as its members?

Gurubatham said: (Jun 26, 2015)  
A 'structure' cannot have member function. Whereas a 'class' can have member function.

P@V@N said: (Sep 6, 2015)  
C++ structs can definitely have member functions. C structs, on the other hand, are a much different beast -- they're essentially arrays that provide names and type information for certain indices.

Neha said: (Jan 6, 2016)  
In C++, a structure can have both variables and functions as members unlike C. In C++ structure, we can also declare some of the members as 'private'.

Akshay said: (Mar 29, 2016)  
In C, it is not allowed to have member function but in C++, it is allowed.

Nikita said: (Jan 28, 2021)  
Are structure members really private? Please explain to me.

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.