I'm not having any trouble accessing my private data within member functions but I am having trouble passing the data to another function within the class. I am relatively new to c++ and I am wondering if I was making some sort of blunderous error. I wanted to set up four public functions to be called from outside the class, and have those functions pass in the correct private data member to a private function within class for execution. I thought this would be good promote code reuse but it doesn't seem to let me do this. Any help would be appreciated.
Header:
class CoaxGage
{
public:
CoaxGage();
~CoaxGage();
bool reconnect();
bool is_connected();
bool disconnect();
bool get_storage_data();
void async_get_storage_data(void);
std::pair<bool,bool> async_get_check_done(void);
bool start_data_storage(void);
void async_start_data_storage(void);
std::pair<bool,bool> async_start_check_done(void);
bool stop_data_storage(void);
void async_stop_data_storage(void);
std::pair<bool,bool> async_stop_check_done(void);
bool clear_storage_data(void);
void async_clear_storage_data(void);
std::pair<bool,bool> async_clear_check_done(void);
private:
std::pair<bool,bool> async_check_done_(std::future<bool> fut);
bool connect_();
bool connected_;
bool get_storage_count_(DWORD &count);
std::vector<FLOAT> values_;
void parse_data_elements_(LS9IF_STORAGE_DATA *data_array, int size);
std::future<bool> get_future_;
std::future<bool> start_future_;
std::future<bool> stop_future_;
std::future<bool> clear_future_;
};
Function passing the data:
std::pair<bool,bool> CoaxGage::async_clear_check_done(void)
{
return async_check_done_(clear_future_);
}
Function receiving the data:
std::pair<bool,bool> CoaxGage::async_check_done_(std::future<bool> fut)
{
bool done, ret = false;
auto status = fut.wait_for(std::chrono::milliseconds(0));
if (status == std::future_status::ready)
{
done = true;
ret = clear_future_.get();
}
return std::make_pair(done, ret);
}
Error:
- error C2248: 'std::future<_Ty>::future' : cannot access private member declared in class 'std::future<_Ty>'