Construct a constant CString?

My MFC code has many declarations like:

const CString error_message = "You made a mistake.";

What does the compiler do with this?  Is the string compiled into the code like a const char[]?  Or does the compiler just ignore the const and construct a regular CString?
LVL 5
Alkali_GuyAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Jaime OlivaresConnect With a Mentor Software ArchitectCommented:
CString content is not allocated until runtime, but the string itself to be assigned, is contained in the .exe at compile time.
0
 
Jaime OlivaresSoftware ArchitectCommented:
An CString object will be created just at the beginning of runtime, and will be constant (you can't assign error_message to any other value at runtime)
0
 
Alkali_GuyAuthor Commented:
Integral type constants don't receive memory allocation other than in executable code, do they?  My question is, if not, do CString objects share this behaviour?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.