Tutorial :Access specifiers in C++



Question:

I've the below code,

template< typename T >  class T1 {   public:      T i;  protected:      T j;  private:      T k;      friend void Test();  };  

The above code has a template class T1 with three members i,j and k and a friend function Test(),

I just want to know that which member/s of T1 will be available in function Test()?

Any help in this regard will be highly appreciated.


Solution:1

I just want to know that which member/s of T1 will be available in function Test()?

i,j and k


Solution:2

All of them (i, j, k) will be available in function Test().

This is what "friend" gives you access to.


Solution:3

Everyone. If it's friend it's friend for good and bad.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »