尝试在向量中使用成员 class 时出错

Error while trying to use a member class in a vector

我正在创建一个包含文件和目录的容器,文件和目录是从称为资源的父 class 派生的 class,我的问题出现在尝试使用directory class, find() 在目录的内容中搜索名称,该内容可以是文件或目录 find() 工作正常,但当我尝试在目录中的目录中使用它得到这个

error: ‘class sdds::Resource’ has no member named ‘find’ 

这里是 find() 函数 ** 尝试在指向目录的资源指针中使用 find 时,错误来自第二个 for 循环。

Resource* find(const std::string& know, const std::vector<OpFlags>& ff =std::vector<OpFlags>()) {
    auto result = std::find(begin(ff), end(ff), OpFlags::RECURSIVE);
    std::string wh = "";
    Resource* qq = nullptr;
    if(result == std::end(ff)){
     for (auto it = std::begin (m_contents); it != std::end (m_contents); ++it) {
    
            if((*it)->name() == know){
        return *it;
        }
    }
    return nullptr;
    }
    
    else{
    for (auto ip = std::begin (m_contents); ip != std::end (m_contents) || qq != nullptr; ++ip) {
        
        while((*ip)->type()==NodeType::FILE){
        ++ip;
        }   
    qq = (*ip)->find(*ip->name());
    }   
    }
    return qq;  
    }

name() returns会员姓名, OpFlags 参数确定它是否应该查看目录内部的目录, NodeType returns 内容的类型 这是目录 class

class Directory: public Resource{
        std::vector<Resource *> m_contents;
    int ccount = 0;
    public:
//stuff
};

这是资源class

class Resource {
    protected:
        // Stores the name of the resource
        std::string m_name{};
        // Stores the absolute path of the folder where the resource is located
        std::string m_parent_path = "/";

    public:
        virtual void update_parent_path(const std::string&) = 0;
        virtual std::string name() const = 0;
        virtual int count() const = 0;
        virtual std::string path() const = 0;
        virtual size_t size() const = 0;
        virtual NodeType type() const = 0;
        virtual ~Resource() {}
    };

如您所见,Resource 没有这样的 find() 成员我知道,我也知道这个问题可能很难理解,对此我深表歉意,我想知道的是如何在目录内的目录中使用find(),只是要注意:我不能修改资源class ,我的整个代码都有效,但那部分。

只需从 qq = (*ip)->find(*ip->name()); 中删除 (*ip)->find 不是成员函数。

qq = find((*ip)->name());

也许应该将标志传递给调用

qq = find((*ip)->name(), ff);