Aman Saleem
Aman Saleem

Reputation: 53

Access specifiers in C++

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.

Upvotes: 0

Views: 362

Answers (3)

Beno&#238;t
Beno&#238;t

Reputation: 16994

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

This is what "friend" gives you access to.

Upvotes: 4

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

Upvotes: 0

Prasoon Saurav
Prasoon Saurav

Reputation: 92874

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

i,j and k

Upvotes: 3

Related Questions