In some computer languages it is possible to do so, but I would not even think or design any application in this way.
A base class SHOULD NEVER know what the derived classes are. Perhaps it was created by generalizing some classes. Even at that point, this new base class should have no knowledge of the derived classes whatsoever.
To do a good OO design, the base class should have a method like getPrivatePartOfDerivedClass() as abstract, then force the derived class to provide the implementation of this method.
There is no such thing. When declaring a friend function only the explicitly-scoped friend is granted private access. The friend function may well be declared virtual within its own class but none of its overrides are granted access unless they are explicitly granted access.
Only that they cannot be inherited by derived classes. This is "a good thing". Other than that, a friend function has full access to a class' private and protected members and you cannot limit its scope.
Only that they cannot be inherited by derived classes. This is "a good thing". Other than that, a friend function has full access to a class' private and protected members and you cannot limit its scope. At this data hiding feature of c++ is broken.
Other than that the friend has privileged access to the private members of the class in which it is declared a friend, there are no implications. However, there has to a be a reason for the friend to require that access.
The keyword is friend. The external function must be declared a friend of the class (from within the class itself) in order to become a member of the class and thus gain access to the private (and protected) members of the class.
There is no such thing. When declaring a friend function only the explicitly-scoped friend is granted private access. The friend function may well be declared virtual within its own class but none of its overrides are granted access unless they are explicitly granted access.
Only that they cannot be inherited by derived classes. This is "a good thing". Other than that, a friend function has full access to a class' private and protected members and you cannot limit its scope.
Only that they cannot be inherited by derived classes. This is "a good thing". Other than that, a friend function has full access to a class' private and protected members and you cannot limit its scope. At this data hiding feature of c++ is broken.
No. De-friend the friend class and provide an access method function.
Only that they cannot be inherited by derived classes. This is "a good thing". Other than that, a friend function has full access to a class' private and protected members and you cannot limit its scope.
We can access a Friend function from any other class in which friend function is introduced or declared even if the other class is not a member of first class. But when we use normal member function, we can have its access only in the derived classes of the first class. This is the basic difference between a friend function and a normal member function.
Other than that the friend has privileged access to the private members of the class in which it is declared a friend, there are no implications. However, there has to a be a reason for the friend to require that access.
In C++, a friend function or friend class can grant access to its private data members to other classes. The public member allows any class to access that data.
The keyword is friend. The external function must be declared a friend of the class (from within the class itself) in order to become a member of the class and thus gain access to the private (and protected) members of the class.
A friend is any class, class method or function that is declared to be a friend of a class. Friends have private access to the classes that declare them friends.
A friend function is a function that cannot be declared a member of a class but which requires private access to that class. For example, a function that operates upon two different classes cannot be a member of both classes, but if the function requires private access to both classes then it has to be a friend to at least one of them.To fully appreciate friend functions, consider that a non-static member function has the following three properties:Has private access to the class.Is scoped to the class.Must be invoked against an object of the class (has a 'this' pointer).Static member functions have the first two properties only while friend functions have the first property only. All other non-member functions have none of these properties.
A normal member function has the following qualities: 1. Has private access to the class. 2. Is scoped to the class. 3. Can be invoked on an instance of the class. Static functions have the first two qualities only. Friend functions have the first quality only. It therefore follows that friend functions are only compulsory when you need quality 1 only.