Solved

Construct a constant CString?

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

743 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now