Skip to Content
Ivor Horton's Beginning Visual C++ 2012
book

Ivor Horton's Beginning Visual C++ 2012

by Ivor Horton
October 2012
Beginner
984 pages
27h 22m
English
Wrox
Content preview from Ivor Horton's Beginning Visual C++ 2012

THE CString CLASS

You used a CString object in the previous section, and there’s more to it than you have seen so far. The CString class provides a convenient and easy-to-use mechanism for handling strings that you can use just about anywhere a string is required. To be more precise, you can use a CString object in place of strings of type const char*, or of type LPCTSTR, which is a type that comes up in Windows API functions. If you are using the DDX mechanism for strings, then you must use CString, otherwise DDX won’t work.

The CString class provides the overloaded operators shown in the following table.

OPERATOR USAGE
= Copies one string to another, as in:str1 = str2;str1 = _T("A normal string");
+ Concatenates two or more strings, as in:str1 = str2 + str3 + _T(" more");
+= Appends a string to an existing CString object, as in:str1 += str2;
== Compares two strings for equality, as in:if(str1 == str2) // do something...
< Tests if one string is less than another.
<= Tests if one string is less than or equal to another.
> Tests if one string is greater than another.
>= Tests if one string is greater than or equal to another.

The variables str1 and str2 in the preceding table are CString objects.

CString objects automatically grow as necessary, such as when you add an additional string to the end of an existing object. For example:

CString str = _T("A fool and your money");
str += _T("are soon partners.");

The first statement declares and initializes the ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Ivor Horton's Beginning Visual C++ 2013

Ivor Horton's Beginning Visual C++ 2013

Ivor Horton
Build Windows 8 Apps with Microsoft Visual C++ Step by Step

Build Windows 8 Apps with Microsoft Visual C++ Step by Step

Paolo Pialorsi Luca Regnicoli and Roberto Brunetti

Publisher Resources

ISBN: 9781118417034Purchase book