如何下标CString? (CSimpleStringT ::运算符[]) [英] How to subscript a CString? (CSimpleStringT::operator[])

查看:97
本文介绍了如何下标CString? (CSimpleStringT ::运算符[])的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在MFC的一个古老的过时版本中,CString表达式可以是下标以便检索一个元素。


Visual Studio 2005定义了CSimpleStringT: :操作符[]。乍一看它好像是b $ b看起来可能是为了向古老程序提供向后兼容性

。但似乎没有办法使用它。


CString s = _T(" ab");

short i = 1;

_TCHAR c = s [i];


错误C2666,模糊过载。


atlsimpstr.h我发现一个运算符[]的整个过度重载。在

cstringt.h中我找不到。另一个在哪里,有没有什么方法可以克服它?

In an antique obsolete version of MFC, a CString expression could be
subscripted in order to retrieve one element.

Visual Studio 2005 defines CSimpleStringT::operator[]. At first glance it
looks like it might have been intended to provide backwards compatibility
for antique programs. But there seems to be no way to use it.

CString s = _T("ab");
short i = 1;
_TCHAR c = s[i];

Error C2666, ambiguous overload.

In atlsimpstr.h I find one whole uniguous overload of operator[]. In
cstringt.h I find none. Where is the other one, and is there any way to
overcome it?

推荐答案

我不知道我不知道[]运算符(我不会使用它),但GetAt()仍然

有效。


Tom


" Norman Diamond" < nd ****** @ community.nospamwrote in message

news:************* @ TK2MSFTNGP03.phx.gbl ...
I don''t know about the [] operator (I don''t use it), but GetAt() still
works.

Tom

"Norman Diamond" <nd******@community.nospamwrote in message
news:Of*************@TK2MSFTNGP03.phx.gbl...

在一个古老的MFC过时版本中,CString表达式可以是

下标以便检索一个元素。

Visual Studio 2005定义了CSimpleStringT :: operator []。乍一看它好像是b $ b看起来可能是为了向古老程序提供向后兼容性

。但似乎没有办法使用它。


CString s = _T(" ab");

short i = 1;

_TCHAR c = s [i];


错误C2666,模糊过载。


atlsimpstr.h我发现一个运算符[]的整个过度重载。在

cstringt.h中我找不到。另一个在哪里,有没有办法克服它?
克服它?
In an antique obsolete version of MFC, a CString expression could be
subscripted in order to retrieve one element.

Visual Studio 2005 defines CSimpleStringT::operator[]. At first glance it
looks like it might have been intended to provide backwards compatibility
for antique programs. But there seems to be no way to use it.

CString s = _T("ab");
short i = 1;
_TCHAR c = s[i];

Error C2666, ambiguous overload.

In atlsimpstr.h I find one whole uniguous overload of operator[]. In
cstringt.h I find none. Where is the other one, and is there any way to
overcome it?


这种语法一直对我有用。我对_TCHAR不熟悉 - 我只是

使用TCHAR。


不确定模糊性的来源。你在构建Unicode吗?

char c = s [1]有效吗? TCHAR c = s [0]是否工作???


-

Jonathan Wood

SoftCircuits编程
http://www.softcircuits.com

" Norman金刚石" < nd ****** @ community.nospamwrote in message

news:************* @ TK2MSFTNGP03.phx.gbl ...
That syntax has always worked for me. I''m not familiar with _TCHAR--I just
use TCHAR.

Not really sure where the ambiguity comes in. Are you building Unicode? Does
char c = s[1] work? Does TCHAR c = s[0] work ???

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
"Norman Diamond" <nd******@community.nospamwrote in message
news:Of*************@TK2MSFTNGP03.phx.gbl...

在一个古老的MFC过时版本中,CString表达式可以是

下标以便检索一个元素。

Visual Studio 2005定义了CSimpleStringT :: operator []。乍一看它好像是b $ b看起来可能是为了向古老程序提供向后兼容性

。但似乎没有办法使用它。


CString s = _T(" ab");

short i = 1;

_TCHAR c = s [i];


错误C2666,模糊过载。


atlsimpstr.h我发现一个运算符[]的整个过度重载。在

cstringt.h中我找不到。另一个在哪里,有没有办法克服它?
克服它?
In an antique obsolete version of MFC, a CString expression could be
subscripted in order to retrieve one element.

Visual Studio 2005 defines CSimpleStringT::operator[]. At first glance it
looks like it might have been intended to provide backwards compatibility
for antique programs. But there seems to be no way to use it.

CString s = _T("ab");
short i = 1;
_TCHAR c = s[i];

Error C2666, ambiguous overload.

In atlsimpstr.h I find one whole uniguous overload of operator[]. In
cstringt.h I find none. Where is the other one, and is there any way to
overcome it?



谢谢,我将使用GetAt()。


我想知道为什么Visual Studio 2005包含一个定义,它看起来像是用于向后兼容的
但是Visual Studio 2005阻止

工作。


Tom Serface < to ******** @ camaswood.com写信息

新闻:0E ********************** ************ @ microsof t.com ...
Thank you, I will use GetAt().

I wonder why Visual Studio 2005 includes a definition which looks like it''s
intended for backwards compatibility but which Visual Studio 2005 prevents
from working.

"Tom Serface" <to********@camaswood.comwrote in message
news:0E**********************************@microsof t.com...

>我不知道[]运算符(我不会用它),但GetAt()仍然可以工作。


Tom


Norman Diamond < nd ****** @ community.nospamwrote in message

news:************* @ TK2MSFTNGP03.phx.gbl ...
>I don''t know about the [] operator (I don''t use it), but GetAt() still
works.

Tom

"Norman Diamond" <nd******@community.nospamwrote in message
news:Of*************@TK2MSFTNGP03.phx.gbl...

>在MFC的古老过时版本中,可以下载CString表达式以便检索一个元素。

Visual Studio 2005定义了CSimpleStringT :: operator []。乍一看,它似乎可能是为了提供古老程序的向后兼容性。但似乎无法使用
它。

CString s = _T(" ab");
short i = 1;
_TCHAR c = s [i];

错误C2666,模糊的重载。

在atlsimpstr.h中,我发现了operator []的一个完全不明显的重载。在
cstringt.h中我找不到。另一个在哪里,有没有办法克服它?
>In an antique obsolete version of MFC, a CString expression could be
subscripted in order to retrieve one element.

Visual Studio 2005 defines CSimpleStringT::operator[]. At first glance
it looks like it might have been intended to provide backwards
compatibility for antique programs. But there seems to be no way to use
it.

CString s = _T("ab");
short i = 1;
_TCHAR c = s[i];

Error C2666, ambiguous overload.

In atlsimpstr.h I find one whole uniguous overload of operator[]. In
cstringt.h I find none. Where is the other one, and is there any way to
overcome it?


这篇关于如何下标CString? (CSimpleStringT ::运算符[])的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆