| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3717 人关注过本帖
标题:[Error] ld returned 1 exit st
只看楼主 加入收藏
九天冥盟
Rank: 2
等 级:论坛游民
威 望:1
帖 子:77
专家分:20
注 册:2015-7-14
结帖率:36%
收藏
 问题点数:0 回复次数:0 
[Error] ld returned 1 exit st

class stack
{
    protected:
        int *data;
        int pos;
    public:
        stack(int i=3)
        {
            cout<<"gou zhao"<<endl;
            data=new int [i];
            pos=i;
        }
        stack(stack &t)
        {
            cout<<"kao bei"<<endl;
            for(int i=0;i<t.pos;i++)
              {
              data[i]=t.data[i];
              }
            pos=t.pos;
        }
        ~stack()
        {
            cout<<"xi gou"<<endl;
            delete []data;
        }
        void input()
        {
            cout<<"pleacs input"<<endl;
            for(int i=0;i<pos;i++)
                 cin>>data[i];
        }
        friend void output( stack &b);
};
void test(stack a)
{
    cout<<"in the function!"<<endl;
}

void output( stack &b)            //为什么这里不可以用普通变量b调用拷贝?
{
    for(int i=0;i<b.pos;i++)
       cout<<b.data[i]<<endl;
}

int main()
{
    int i;
    cout<<"plecse input number:";
    cin>>i;
    stack x(i);
    x.input();
    stack y;
    y=x;
    output(y);
    return 0;
}
为什么总是报错:
   [Error] ld returned 1 exit status
我的目的是验证拷贝函数的调用情况
        还有一个问题:为什么不可以 stack y=x;初始化式的调用拷贝函数?
搜索更多相关主题的帖子: public bottom color 
2016-04-24 00:29
快速回复:[Error] ld returned 1 exit st
数据加载中...
 
   



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

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