摘要:
什么是友元函数? 友元函数(friend function)是C++中一个特殊的函数类型。它不是类的成员函数,但它可以访问类的私有(private)和保护(protected)成员。友元函数提供了一种突破类封装的机制,允许在类之外的代码访问类的私有和保护成员。 当你想要让某个函数访问一个类的私有和保 阅读全文
posted @ 2023-04-11 10:30
漓川
阅读(37)
评论(0)
推荐(0)
摘要:
#例35 #include <iostream> #include <math.h> using namespace std; class Point { public: Point(float x1, float y1) : x(x1), y(y1) {} void show() { cout < 阅读全文
posted @ 2023-04-11 10:13
漓川
阅读(14)
评论(0)
推荐(0)