What is the main reason of using a friend class? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 2

What is the main reason of using a friend class?

9th Feb 2017, 4:37 PM
Md Shoriful Islam
Md Shoriful Islam - avatar
7 ответов
+ 3
so that we can access private properties of a class
9th Feb 2017, 5:24 PM
Wazed Ali Gazi
Wazed Ali Gazi - avatar
+ 3
as its name suggests friend function provides us a gateway to access the private members of a class
11th Feb 2017, 7:25 PM
kaushal kumar
kaushal kumar - avatar
+ 1
friend is a special mechanism for letting non member functions access private data. A Friend function can be either declared or defined within the scope of a class definition.
14th Feb 2017, 11:21 AM
Deepika Behera
Deepika Behera - avatar
+ 1
OK. thanks all
14th Feb 2017, 11:30 AM
Md Shoriful Islam
Md Shoriful Islam - avatar
+ 1
We normally use friend functions when we have to link data between two different classes ( in few cases inheritance isn't required as all the properties of one class aren't need by the other)
16th Feb 2017, 5:22 PM
Pramod Nagaraj
Pramod Nagaraj - avatar
0
OK. thanks all
14th Feb 2017, 11:30 AM
Md Shoriful Islam
Md Shoriful Islam - avatar
0
yes.. pramod
17th Feb 2017, 7:10 AM
Md Shoriful Islam
Md Shoriful Islam - avatar