标题:求字符串长度 总是说 ch 没有定义,我定义了结果错得更多了,该怎么办? 帮 ...
取消只看楼主
晓小晓小
Rank: 2
等 级:论坛游民
帖 子:12
专家分:38
注 册:2014-5-15
结帖率:66.67%
已结贴  问题点数:20 回复次数:0 
求字符串长度 总是说 ch 没有定义,我定义了结果错得更多了,该怎么办? 帮看看吧!
#include<iostream>
#include<string>
using namespace std;
class strtype
{
public:
    string  ch;
    int show();


};
int show()
{
    int len=0;
while(ch!='\0')
{
    len++;
}
cout<<"字符串的长度"<<len<<endl;
return 0;
}
int main()
{
strtype *p;
p=new strtype;
cout<<"Creating string"<<endl;
p->ch="we study new and delete";
cout<<"Deleting string"<<endl;
return 0;

}  
搜索更多相关主题的帖子: public 字符串 include 
2014-06-10 22:42



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-432765-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.336376 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved