Link to home
Start Free TrialLog in
Avatar of Alkali_Guy
Alkali_Guy

asked on

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?
Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

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)
Avatar of Alkali_Guy
Alkali_Guy

ASKER

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?
ASKER CERTIFIED SOLUTION
Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial