以下哪项更好? [英] Which of the following is better?

查看:92
本文介绍了以下哪项更好?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

鉴于

TCHAR szString [] = _T(Sample);

CString stString;





以下哪项更好

1. stString + = szString; //编辑修复类型(orignal:sString)

2. stString + =(LPCTSTR)szString;



问题摘要:

当使用空终止字符串连接Cstring时,建议转换为(LPCTSTR)以使其弹出警告?

解决方案

这个问题没有感觉到了。如果两条线完全不同,你怎么能问哪一条更好?

此外,如果你已经使用 CString ,为什么要使用<$完全是c $ c> LPTSTR (好吧,也许只是为了与某些现有代码兼容)。另外,您是否考虑使用标准字符串 std :: string



-SA

Given that
TCHAR szString[] = _T("Sample");
CString stString;


which of the following is better
1. stString += szString; // Edited to fix type (orignal: sString)
2. stString += (LPCTSTR)szString;

Summary of question:
When concatenating a Cstring with a null terminated string is it advisable to cast to (LPCTSTR) to elimate warning?

解决方案

The question makes no sense at all. If two lines do completely different things, how can you ask which one is better?
Besides, if you already use CString, why using LPTSTR at all (well, maybe only for compatibility with some existing code). Also, did you consider using standards strings std::string?

—SA


这篇关于以下哪项更好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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