C26444 Avoid unnamed objects with custom construction and destruction (es.84)

倖福魔咒の 提交于 2020-07-22 04:38:17

问题


Can anyone help me solve the problem?? Before when I had only one method for class, which was void show(vector &list, string &filter), get&display functions were in it, then i decided to split those functions into vector get() & void display() but when i return a new modified vector from vector get() the error appears:

C26444 Avoid unnamed objects with custom construction and destruction (es.84).

Here's a short code example for realization:

#include <iostream>
#include <vector>
#include <string>

using namespace std;

class Test
{
//variables
};

class Base
{
public:
    virtual vector<Test>get(vector<Test>& list, string& filter) = 0;
    virtual void display() = 0;
};
class A : public Base
{
    string a;
    string b;
    vector<Test> aList;

public:
    vector<Test>get(vector<Test>& list, string& filter)
    {
        //modifying info and placing to vector<Test> aList
        return aList;
    }
    void display()
    {
        //show aList
    }
};

int main()
{
    vector<Test> list;
    //define list
    string filter;
    //define filter

    Base* object = new A();
    object->get(list, filter);
    object->display();
    return 0;
}

来源:https://stackoverflow.com/questions/59634866/c26444avoid-unnamed-objects-with-custom-construction-and-destruction-es-84

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!