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?
class can have member functions while structure cannot.
class data members are public by default while that of structure are private.
Pointer to structure or classes cannot be declared.
class data members are private by default while that of structure are public by default.
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
23 comments Page 3 of 3.

Samba said:   1 decade ago
In C++ we can do
>
> struct Box{
> int x;
> int y;
> void function(){cout<<x<<" "<<y<<endl;};
> }

Harsh said:   1 decade ago
I agree with shivam. Because only class have the membr function structure don't have the member function.

Shivam said:   1 decade ago
Even the option A is correct. We don't have member functions declared in class.


Post your comments here:

Your comments will be displayed after verification.