Friend classes are used when two or more classes are designed to work together and virtual base class aids in multiple inheritance
Friend Class: This is a commitment from the class where the other class is declared as Friend Class.
If Class B declared as a friend class in Class A, theb B has the access to all the members and functions (private, public and protected). But here the reverse is not true. i.e. A does not have the same priveleges over B.
Virtual Function: During Multiple inheritance when a class is derived from two different classes having a common function, then teh derived class contains 2 different copies of the common function. The virtual key word is used there to avoid having 2 copies of the same functin.
Example:
Class A{ Public: Func(); }
Class B:virtual public A{ } Class C:virtual public A{ } Class D:public B,public D { }
Here in the above example B, C inherit the same copy of Func(). Now D inherits teh same Func() from B and C. The Virtual keyword is used to avoid this.