小编use*_*346的帖子

C++,错误与operator <<不匹配

请指导我.我必须编写一个程序,其中包含一个名为的类VectorCollection,用于存储实例为string类型的向量集合.我收到以下错误

在std :: cout中没有匹配operator <<

当我尝试使用输出矢量 cout << (*it) << endl;

我有点不愿意在论坛上提出完整的作业问题,但为了避免在这里出现混淆.我想我可能完全偏离轨道,所以任何指导都会受到影响.

编写一个包含名为VectorCollection的类的cpp程序,该类将用于存储实例的类型为string的向量集合.编写一个参数构造函数,该构造函数接收一个字符串数组,用于初始化集合中的值.添加函数以向集合添加实例,从集合中删除实例,从集合中删除所有条目并显示整个集合.同时覆盖*运算符,使其返回两个VectorCollection对象的交集.编写一个程序来测试类中所有成员函数和重载运算符.接下来,修改main函数,以便不是为每个Movie对象创建单独的变量,而是使用样本数据创建至少4个Movie对象的数组.循环播放数组并输出四部电影中每部电影的名称,MPAA等级和平均等级.

//movies.h
//******************************************************************************************************
using namespace std;


#ifndef movies_H
#define movies_H

class VectorCollection
{
    //member variables
        string newtitle,newgentre,newmpaa,newrating;
        vector<VectorCollection> movies;

    public:
        //function declarations

        //default constructor
        VectorCollection();

        //overload constructor
        VectorCollection(string,string,string,string);

        //destructor
        ~VectorCollection();

        void settitle(string);
        void setgentre(string);
        void setmpaa(string);
        void setrating(string);
        void display(vector<VectorCollection>);

};

 #endif // MOVIES_H_INCLUDED


//movies.cpp
//******************************************************************************************************
//constructor definition
VectorCollection::VectorCollection()
{

}

//overloaded constructor def
VectorCollection::VectorCollection(string title,string gentre,string mpaa,string rating)
{
    newtitle = title;
    newgentre = gentre; …
Run Code Online (Sandbox Code Playgroud)

c++

1
推荐指数
1
解决办法
362
查看次数

标签 统计

c++ ×1