2017-04-25 11 views
0

....얻기 invalig 사용 나는 비 정적 변수로 제대로 변수 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; 
} 

오류 :

| 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)) 
|    ^

답변

2

귀하의 방법 write_params 클래스 ILV_file_operations::Response의 일원이지만, 객체없이 클래스 ILV_file_operations의 비 정적 멤버 변수에 액세스하려고합니다.
먼저 구성원에 액세스하려면 ILV_file_operations 클래스의 개체가 필요하거나 구성원은 static이어야합니다.
그러나 여전히 private이기 때문에 멤버 변수에 액세스 할 수 없으며 내부 클래스가 외부 클래스의 멤버 변수에 자동으로 액세스하지 못합니다.