1. 程式人生 > >c++與java中關於訪問修飾符的區別

c++與java中關於訪問修飾符的區別

#include <iostream>
#include <math.h>
using namespace std;
class A
{


protected:
void fun()
{
cout<<"hello"<<endl;
}
};
int main(){
A a;
a.fun();
return 0;
}

c++中則報錯error C2248: 'fun' : cannot access protected member declared in class 'A'