友元函数访问对象中的成员可以不通过对象名?
牛客上给的答案是否,为什么啊?
下面的代码输出的是10,访问静态成员还要通过对象名吗?还是说认为静态成员不属于对象,所以这种情况不算?
#include <iostream>
#include <algorithm>
using namespace std;
class Sales_data {
public:
const static int sd=10 ;
private:
int privateData ;
friend void outPut( ) ;
};
void outPut()
{
cout<< Sales_data::sd << endl;
}
int main( )
{
outPut();
}
