Solved

Construct a constant CString?

Posted on 2004-08-22
3
204 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

628 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