void指針訪問成員函數(shù)
如果成員函數(shù)沒有用到this指針起惕,那么空指針可以直接訪問
如果成員函數(shù)用到this指針,要注意加if判斷涡贱,如果this為NULL,return
常函數(shù)
格式: void func() const{}
常函數(shù) 修飾是this指針惹想,const Type* const this
常函數(shù)不能修改this指針指向的值
常對象
在對象前加入const 修飾
格式:const person p
常對象不可以調(diào)用普通函數(shù)问词,只能調(diào)用常函數(shù)
成員變量
成員變量前加mutable,在常函數(shù)中可以修改