如何解决错误C2039:'size':不是'CString'的成员 [英] How to solve error C2039: 'size' : is not a member of 'CString'

查看:210
本文介绍了如何解决错误C2039:'size':不是'CString'的成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在我的程序中出现此错误 C2039:``size'':不是``CString''的成员.
怎么解决呢?帮帮我.

Hi ,

In my program I got this error C2039: ''size'' : is not a member of ''CString''.
How to solve it? help me.

BOOL CEMailDlg::Validate() 
{  
	CString m_sFrom;
	
	for(int a = 0; a < m_sFrom.size(); a++) 
	{  
		if(m_sFrom.at(a) = '@') 
			return true;
   }   return false;
}


谢谢您

推荐答案

您是要使用GetLength吗? MSDN [
Did you mean to use GetLength? MSDN[^]

for(int a = 0; a < m_sFrom.GetLength(); a++)


如果有内存,请尝试使用m_sFrom.GetLength()代替

只需阅读代码-对于您要尝试做的事情,最好不要使用:

If memory serves: try m_sFrom.GetLength() instead

Just read the code - for what you are trying to do wouldn''t it be better to use:

return (m_sFrom.Find( ''@'' ) != -1)





instead of searching manually?


"size"和"at"是basic_string的成员函数.
1)包含basic_string头文件
#include< string>
使用名称空间std;

"size" and "at" is a member function of basic_string.
1) include basic_string header file
#include <string>
using namespace std;

Replace CString m_sFrom; with string m_sFrom;



2)如果您仍然想使用CString而不是



2) If you still want to use CString than

BOOL CEMailDlg::Validate() 
{  
	CString m_sFrom;
	
	for(int a = 0; a < m_sFrom.GetLength(); a++) 
	{  
		if(m_sFrom.GetAt(a) == ''@'') 
			return true;
   }   return false;
}


这篇关于如何解决错误C2039:'size':不是'CString'的成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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