c ++查找字符串
Program 1:
程序1:
#include <iostream>
using namespace std;
class Sample {
int A, B;
friend void fun();
};
void fun()
{
Sample S;
S.A = 10;
S.B = 20;
cout << S.A << " " << S.B << endl;
}
int main()
{
fun();
return 0;
}
Output:
输出:
10 20
Explanation:
说明:
Here, we created a class Sample that contains private data members A and B.
在这里,我们创建了一个类Sample ,其中包含私有数据成员A和B。
As we know that, we cannot access the private members outside the class. Here, we defined a non-member function as a fri