mirror of
https://github.com/Light-City/CPlusPlusThings.git
synced 2026-04-02 02:03:08 +08:00
update
This commit is contained in:
28
basic_content/friend/friend_class.cpp
Normal file
28
basic_content/friend/friend_class.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class A
|
||||
{
|
||||
public:
|
||||
A(int _a):a(_a){};
|
||||
friend class B;
|
||||
private:
|
||||
int a;
|
||||
};
|
||||
|
||||
class B
|
||||
{
|
||||
public:
|
||||
int getb(A ca) {
|
||||
return ca.a;
|
||||
};
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
A a(3);
|
||||
B b;
|
||||
cout<<b.getb(a)<<endl;
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user