C++ Programming - OOPS Concepts - Discussion

Discussion Forum : OOPS Concepts - General Questions (Q.No. 4)
4.
Which of the following is not the member of class?
Static function
Friend function
Const function
Virtual function
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
42 comments Page 4 of 5.

Yogeshwar bargal said:   1 decade ago
I dont know what is cont class?

Abhishek porwal said:   1 decade ago
Private data member can acess out side the class with the help of friend function. (i.e) we can access the private data member of the base class in drived class so we use friend function.

Shruti Ganesh said:   1 decade ago
A class can have different types of MEMBER functions or methods. These can be static, virtual or constant.

These are functions of the class and belong to the class. However, a friend function is one such type of function which can access the private data members of a class and is not a MEMBER function.

Why do we need them? 'cause there are times when you need to access private data members with an external function. Using too many friend functions disintegrates the privacy of the object. They should be used only when necessary.

Sandesh said:   1 decade ago
A const member function cannot modify any of the data members of its class. This is used by programmers to prevent accidental modification of data members.

One more thing is that const memb function can modify only those data members that are declared as mutable.

Yogesh said:   1 decade ago
Virtual function can be used in derived class.

Mohamed Rafeek said:   1 decade ago
In a class, the private data can be accessed only by the public member function of that class. C++ provides a mechanism in which a non member can have access to the private member of a class. This is achieved by the non_member function "friend" to the class, whose private data can be accessed.

Maha said:   1 decade ago
Why we are using virtual function in dynamic binding ?

Kavita said:   1 decade ago
I agree with Amruta and virtual function is used for dynamic binding. If a virtual function is defined in the base class, it need not be necessarily redefined in the derived class. In such cases, class will invoke the base function.

Selvakumar said:   1 decade ago
What is virtual function ?

Srikanth said:   1 decade ago
A const function is one, which doesn't allow any modification or change its instance variable's data (member data).


Post your comments here:

Your comments will be displayed after verification.