VC6.0下string不能用pusk_back,可用+=代替

2013-09-11 21:14:32

在VS下运行正确的代码,拿到VC6.0下,编译出错,提示:

 error C2039: 'push_back' : is not a member of 'basic_string<char,struct std::char_traits<char>,class std::allocator<char> >'

在网上查了一下,好像是VC6.0对STL支持不是很好,在http://cboard.cprogramming.com/cplusplus-programming/76579-back_inserter-string.html的帖子中,看到用+=不会出错,试了一下,果然如此。

而且,push_back、insert、append在VC6.0下都不行,+=可以:

 

1     //sum.push_back(tmpSum + '0');
2         //sum.insert(tmpSum + '0');
3         //sum.append(tmpSum + '0');
4         sum += (tmpSum + '0');

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值