标题:字符串变量使用 但是系统一直提示没有 声明字符串类
取消只看楼主
愿o圆o安
Rank: 1
等 级:新手上路
帖 子:30
专家分:0
注 册:2017-3-13
结帖率:25%
 问题点数:0 回复次数:0 
字符串变量使用 但是系统一直提示没有 声明字符串类
#include<iostream.h>
#include<string>

class str
{
private:
    string zfc[5];
public:
    void input();
    void compare();
    void print();
};

void str::input()
{
    cout<<"please enter:"<<endl;
    for(int i=0;i<5;i++)
        cin>>zfc[i];
}

void str::compare()
{
    string step;
    for(int i=0;i<4;i++)
        for(int j=i;j<4-i;j++)
        {
            if(zfc[j]<zfc[j+1])
            {
                step=zfc[j];
                zfc[j]=zfc[j+1];
                zfc[j+1]=step;
            }
        }
}

void str::print()
{
    for(int i=0;i<5;i++)
        cout<<zfc[i]<<endl;
}

void main()
{
    str country;
    country.input();
    ();
    country.print();
}
搜索更多相关主题的帖子: private compare include public please 
2017-04-06 00:04



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




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

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