C++ c+中非静态数据成员错误的无效使用+;

C++ c+中非静态数据成员错误的无效使用+;,c++,non-static,C++,Non Static,下面的代码有什么问题吗?即使我正确地使用了变量file_op作为非静态变量,并且正确地声明了以下错误 class ILV_file_operations: public ILV_command { private: /** * \copydoc ILV_command::ILV_command_request */ class Request: public ILV_command_request<ILV_file_operations>

下面的代码有什么问题吗?即使我正确地使用了变量file_op作为非静态变量,并且正确地声明了以下错误

class ILV_file_operations: public ILV_command
{
private:
    /**
     * \copydoc ILV_command::ILV_command_request
     */
    class Request: public ILV_command_request<ILV_file_operations>
    {
        friend class ILV_file_operations;
        // New format parameters
        uint32_t file_op;
        std::string file_path;
        std::string file_read_data;
        uint8_t request_status; //!<  Response status
    public:
        explicit Request(ILV_file_operations& parent_ref);
        ~Request();

        /**
         * \brief This is method to read the parameters received in the request.
         * \return
         * \arg \c Length: Length of the request data read
         */
        uint32_t read_params();
    };

    class Response: public ILV_command_response<ILV_file_operations>
    {
        friend class ILV_file_operations;
        //New parameter
        std::list<Sub_ILV> param_ILV; ///< Parameter ILV

        // Old format parameters
        std::string file_write_data; ///< Serial number
        uint8_t response_status; //!<  Response status
    public:
        explicit Response(ILV_file_operations& parent_ref);
        ~Response();

        /**
         * \brief This is method to calculate the length of the response to be sent.
         * \return
         * \arg \c Length: Length of the response data
         */
        uint32_t calculate_length();
        /**
         * \brief This is method to write the parameters in the response.
         * \return
         * \arg \c Length: Length of the response data written
         */
        uint32_t write_params();
    };

    Response resp_data; ///< Response data object
    Request req_data; ///< Request data object

public:

    /**
     * \copydoc ILV_command::ILV_command
     */
    explicit ILV_file_operations(boost::shared_ptr<Protocol>& prtcl);
    /**
     */
    virtual ~ILV_file_operations();

    void process();
    uint32_t read_packet();
    uint32_t write_packet();
};


uint32_t ILV_file_operations::Response::write_params()
{
    uint32_t ret_val = 0;

    if (((int)req_data.file_op) == ((int)file_operation_type::write))
    {
        ret_val += parent.cmd_prot->write_string(file_write_data);
    }
    return ret_val;
}
类ILV_文件_操作:公共ILV_命令
{
私人:
/**
*\copydoc ILV_命令::ILV_命令请求
*/
类请求:公共ILV_命令_请求
{
友元类ILV_文件_操作;
//新格式参数
uint32\u t文件\u op;
std::字符串文件路径;
std::字符串文件读取数据;
uint8请求状态;//!<响应状态
公众:
显式请求(ILV文件操作和父文件引用);
~Request();
/**
*\brief这是读取请求中接收到的参数的方法。
*\返回
*\arg\c Length:读取请求数据的长度
*/
uint32读取参数();
};
类响应:公共ILV_命令_响应
{
友元类ILV_文件_操作;
//新参数
std::list param_ILV;//write_字符串(文件写入数据);
}
返回返回值;
}
错误:

| Compiling core_app/src-libs/libCommand_manager/src/ILV_commands/ILV_file_operations.cpp ...
| In file included from core_app/src-libs/libCommand_manager/src/ILV_commands/ILV_file_operations.cpp:11:0:
| ../include/ILV_commands/ILV_file_operations.h: In member function 'virtual uint32_t Dist_cmd_processor::ILV_file_operations::Response::write_params()':
| ../include/ILV_commands/ILV_file_operations.h:82:13: error: invalid use of non-static data member 'Dist_cmd_processor::ILV_file_operations::req_data'
|      Request req_data; ///< Request data object
|              ^
| /home/sagar/morpho/MASigma_Firmware_REV_1.0.10/src-ma5g/core_app/src-libs/libCommand_manager/src/ILV_commands/ILV_file_operations.cpp:84:15: error: from this location
|      if (((int)req_data.file_op) == ((int)file_operation_type::write))
|                ^
|编译核心应用程序/src libs/libCommand_manager/src/ILV_commands/ILV_file_operations.cpp。。。
|在core_app/src libs/libCommand_manager/src/ILV_commands/ILV_file_operations包含的文件中。cpp:11:0:
|../include/ILV_commands/ILV_file_operations.h:在成员函数“virtual uint32_t Dist_cmd_processor::ILV_file_operations::Response::write_params()”中:
|../include/ILV_commands/ILV_file_operations.h:82:13:错误:非静态数据成员'Dist_cmd_processor::ILV_file_operations::req_data'的使用无效
|请求请求数据;//<请求数据对象
|              ^
|/home/sagar/morpho/MASigma_Firmware_REV_1.0.10/src-ma5g/core_app/src libs/libCommand_manager/src/ILV_commands/ILV_file_operations.cpp:84:15:错误:来自此位置
|if(((int)req_data.file_op)==((int)file_operation_type::write))
|                ^

您的方法
write_params
是类
ILV_文件_操作::Response
的成员,但它尝试访问类
ILV_文件_操作
的非静态成员变量,而不使用对象。
首先,您可能需要类
ILV\u file\u operations
的对象来访问其成员,或者该成员必须是
静态的


但是您仍然无法访问成员变量,因为它们是
私有的
,并且您的内部类不能自动访问其外部类的成员变量。

您的方法
write_params
是类
ILV_file_operations::Response
的成员,但是它尝试访问类
ILV\u文件\u操作的非静态成员变量,而不使用对象。
首先,您可能需要类
ILV\u file\u operations
的对象来访问其成员,或者该成员必须是
静态的

但是您仍然无法访问成员变量,因为它们是私有的,并且内部类不能自动访问外部类的成员变量