Solved

Construct a constant CString?

Posted on 2004-08-22
3
203 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sameEnds challenge 3 196
sumHeights2  challenge 7 139
wordmultiple challenge 12 170
Increment column based of a FK 8 68
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…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.

734 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