简体   繁体   English

C ++中的访问说明符

[英]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(), 上面的代码具有一个模板类T1,该模板类具有三个成员i,j和k,以及一个朋友函数Test(),

I just want to know that which member/s of T1 will be available in function Test()? 我只想知道T1的哪个成员可以在函数Test()中使用?

Any help in this regard will be highly appreciated. 在这方面的任何帮助将不胜感激。

All of them (i, j, k) will be available in function Test(). 它们(i,j,k)都将在函数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. 如果是朋友,那就是好与坏的朋友。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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