I work with several HID devices, all of which have classes based on the following base class (in main.h):
class HIDDevice { public: hid_device *device; virtual void read(std::fstream)=0; virtual void write(std::fstream)=0; };
Here is one of the device classes derived from it (device.h):
class MyDevice : public HIDDevice { public: void read(std::fstream); void write(std::fstream); };
... and implementation example:
void MyDevice::read(std::fstream file) {
... and the caller:
fstream file (filename, ios::binary | ios::in); dev->read(file);
When I try to compile, I get the following error:
main.cpp: 294: 27: error: using the remote function 'std :: basic_fstream :: basic_fstream (const std :: basic_fstream &)
In the file included from source / main.cpp: 24: 0: / usr / include / c ++ / 4.6 / fstream: 761: 11: error: 'std :: basic_fstream :: basic_fstream (const std :: basic_fstream &) implicitly deleted as the default definition will be poorly formed:
... and I have no idea why, probably because I'm fairly new to C ++ and I did something stupid.
By changing the arguments to the links (using &), I get the following error:
/main.o :(. rodata._ZTV13MyDevice [vtable for MyDevice] + 0x18): undefined reference to `MyDevice :: write (std :: basic_fstream> &) '
Can someone help me fix this problem?
c ++ inheritance class fstream
Andy e
source share