c++结构体中string类作成员,如何作初始化

[复制链接]
查看11 | 回复2 | 2013-10-30 06:29:51 | 显示全部楼层 |阅读模式
补充:int main(){ using namespace std;// CandyBar snack=// {// // \\\"Mocha Munch\\\",// 2.3,// 350// };// // coutsnack.styleendl;// coutsnack.weightendl;// coutsnack.kllendl; CandyBar sncck; getline(cin,sncck.style); cinsncck.weight; cinsncck.kll; coutsncck.styleendl; coutsncck.weightendl; coutsncck.kllendl; return 0;}在初始化snack时有问题,后面没问题!
               
       
       
                 查看原帖
回复

使用道具 举报

千问 | 2013-10-30 06:29:51 | 显示全部楼层
以下代碼僅供參考:
struct theSct
{
std::string str;
std::string str2;
theSct()
:str(\\\"\\\")
,str2(\\\"\\\")
{
}
}
回复

使用道具 举报

千问 | 2013-10-30 06:29:51 | 显示全部楼层
<img src=\\\"http://wenwen.soso.com/p/20130706/appbig-20130706045539-3264840576966004.jpg\\\"></img>
                        鱼C工作室为大家提供最有趣的编程视频教学,完全免费的哦~
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行