`

Const study record in c++ for temp

阅读更多

Normall const variable:

  Your can’t change it even if you defined a variable as a const

  Int const x = 2 or const int x = 2

 

Const object :

  Const Dog mimi or Dog const mimi

 

Const pointer and refer

  char * const prt1 = string prt1;   ---- a const pointer to a string

  it is wrong that give prt1 the value like ptr1 = string prst2 , you can use *prt1 = “m”

  but

  const * ptr2 = string prt1;

  *prt2 = “x”  is wrong prst2 = stirng prt1 is ok

 

  const double & v;

 

Const function :

  Only constf function can operate const variable

void R::print() const
{
cout<<R1<<";"<<R2<<ENDL;
}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics