int i;
int &p=i;
const int &p=i;
int *pp=&i;
int* &p=pp;
const int* &p;
int const *&p;
int * const&p;
int * &const p;//warning maybe syntax error.
int& *p/??syntax error.
class A
{
private:
int* pInt;
int a;
public:
A()
{
pInt=new int[100];
//pClass=new B[100];
//B b[5]={B(0),B(1),...};
memset(pInt,0,sizeof(int)*100);
}
void g(int i) const
{
pInt[i]=i;
i=3;
}
void f(int i) const
{
a=i;
}
};
C++中const的各种用法(待分析)
最新推荐文章于 2022-08-10 17:42:05 发布