简体   繁体   中英

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.

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

This is what "friend" gives you access to.

我只想知道T1的哪个成员可以在函数Test()中使用?

i,j and k

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM