How to properly use a class object (serial) inside my class (UART) object?
The class object that I want to copy has its copy constructor declared in "Private" and my compiler says:
‘serial::Serial::Serial(const serial::Serial&)’ is private within this context
UART::UART(const serial::Serial& serial_port) : _serial(serial_port), _letter(" ") {}
And the definition of
serial::Serial::Serial(const serial::Serial&)
is:
private:
// Disable copy constructors
Serial(const Serial&);
This is my class header file:
class UART
{
private:
serial::Serial _serial;
public:
UART(const serial::Serial& serial_port) : _serial(serial_port) {};
~UART();
bool read(std::string &data);
bool write(std::string &data);
};
As you can see, I have declared a class object called _serial and I just want to use this object inside UART class and I usually do this by copy construction method (passing serial object to the construction of UART and copy it)
So if the serial class does not allow a copy constructor (because it has been declared in the private section) how can I copy it (or may be other approach?) and use this object inside my UART class?