C++

Topic: Templates

What is a friend function & its advantage?

if we want to write same function/s with the same body in two or more than two classes. We use the keyword friend in front of the that function declaration in the class. by using friend function we can reduce the size if program.<br>example:-<br>there are two classes EMPLOYEE and MANAGER.<br>and there is a function INCOMETEX. every employee and manager have to pay incometax.. in such case we use friend function infront of the INCOMTEX function.

Browse random answers: