What is a friend function & its advantage?

Answer Posted / supriya

friend function is the one that can access the private data
members of the class to which it is made as friend. this is
advantageous when any class needs any computation which
requires the private data members of two different classes.
in such case that class can be made as friend to both the
classes whose data it needs

Is This Answer Correct ?    27 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is difference between class template and template class?

2157


What is abstract class in oop?

526


Whats oop mean?

584


Where You Can Use Interface in your Project

1421


What does oop mean in snapchat?

677






What is the highest level of cohesion?

571


#include #include #include #include void insert(struct btreenode **, int); void inorder(struct btreenode *); struct btreenode { struct btreenode *leftchild; struct btreenode *rightchild; int data; }; main() { struct btreenode *bt; bt=(struct btreenode *)NULL; int req,i=1,num; clrscr(); printf("Enter number of nodes"); scanf("%d",&req); while(i<=req) { printf("Enter element"); scanf("%d",&num); insert(&bt,num); i++; } inorder(bt); } void insert(struct btreenode **sr, int num) { if(*sr==NULL) { *sr=(struct btreenode *)malloc (sizeof(struct btreenode)); (*sr)->leftchild=(struct btreenode *)NULL; (*sr)->rightchild=(struct btreenode *)NULL; (*sr)->data=num; return; } else { if(num < (*sr)->data) insert(&(*sr)->leftchild,num); else insert(&(*sr)->rightchild,num); } return; } void inorder(struct btreenode *sr) { if(sr!=(struct btreenode *)NULL) { inorder(sr->leftchild); printf("\n %d",sr->data); inorder(sr->rightchild); } else return; } please Modify the given program and add two methods for post order and pre order traversals.

3246


What is encapsulation process?

575


What are the two different types of polymorphism?

666


What is pointer in oop?

533


write string class as your own class in java without using any built-in function

1975


What is solid in oops?

598


Whats is abstraction in oops?

585


What is use of overloading?

603


What is class in oop with example?

611