You are here:

C++/why const member, reference member can only be initialized not assigned

Advertisement


Question
why const member, reference member can only be initialized not assigned?

I read a couple of books that tells this, but seems not one can explain why


thanks

Answer
The reason for reference should be initialized when they are created is aside from initialization you cannot change what object a reference variable points to.
Member specified as const cannot be changed by your program.A const variable will either receive its value by explicit initialization or hardware dependent means.

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


rakshitha

Expertise

Difficult questions related to C .

Experience

C ,vc ,opc ,windows CE, ActiveX

Education/Credentials
Masters in electrical engineering

©2016 About.com. All rights reserved.