标题:求教这段程序哪错误
取消只看楼主
qq826647235
Rank: 2
等 级:论坛游民
帖 子:37
专家分:10
注 册:2016-5-4
结帖率:63.64%
已结贴  问题点数:20 回复次数:1 
求教这段程序哪错误
程序代码:
#include<iostream>
#include<memory>
#include<string>
#include<vector>

using namespace std;

class Strblob
{
public:
    typedef vector<string>::size_type size_type;
    Strblob();
    Strblob(vector<string> a);
    void printfff()
    {
        for (auto a : *data)
        {
            cout << a << endl;
        }
    }
private:
    shared_ptr <vector<string>> data;
};
Strblob::Strblob() :data(make_shared<vector<string>>){}
Strblob::Strblob(vector<string>a): data(make_shared<vector<string>>(a)){}

int main()
{
    Strblob a = { { "a", "b", "c" } };
    Strblob b = a;
    b.printfff();
    getchar();
}


编译时出错了。说delete不能删除不是指针的对象。我搞不清楚哪段代码用了delete。
2017-02-27 23:27
qq826647235
Rank: 2
等 级:论坛游民
帖 子:37
专家分:10
注 册:2016-5-4
得分:0 
回复 2楼 rjsp
为什么要单独加个友元
2017-02-28 16:39



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




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

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