Solved

Construct a constant CString?

Posted on 2004-08-22
3
200 Views
Last Modified: 2013-11-20
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?
0
Comment
Question by:Alkali_Guy
  • 2
3 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 11865002
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
 
LVL 5

Author Comment

by:Alkali_Guy
ID: 11865114
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
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 45 total points
ID: 11865299
CString content is not allocated until runtime, but the string itself to be assigned, is contained in the .exe at compile time.
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
sumNumber challenge 16 122
Sed question 2 86
Problem to open Excel file 15 135
Capture logon name 13 73
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question