#include <string>
#include <iostream>

using std::cout;
using std::string;

class data_operator {
private:
	bool _is_saved;
public:
	data_operator() : _is_saved(true) { }
	virtual bool can_proceed() = 0;
};

class reader : public virtual data_operator {
private:
	bool _is_reading;
public:
	reader() : _is_reading(false) { }
	bool can_proceed() { return /* true if not EOF */ true; }
};

class network_writter : public virtual data_operator {
private:
	string _addr;
public:
	network_writter(string addr)
		: _addr(addr) {
	}
	bool can_proceed() { return /* true if connection is alive */ true; }
};

class iosubsys : public reader, public network_writter {
public:
	iosubsys(string remote_addr) : network_writter(remote_addr) { }
	// must implement pure virtual can_proceed()
	bool can_proceed() {
		return reader::can_proceed() || network_writter::can_proceed(); // does not really make sense
	}
};

int main() {
	iosubsys obj("192.168.0.5");

	// gdb reports the following object layout in memory:
	//
	// obj {
	// 		<reader> = {
	// 			<data_operator> = { // <-- !!! no replication of data_operator !!!
	// 				_vptr.data_operator = 0x8048c2c,
	// 				_is_saved = true
	// 			},
	// 			_vptr.reader = 0x8048c0c,
	// 			_is_reading = false
	// 		},
	// 		<network_writter> = {
	// 			_vptr.network_writter = 0x8048c1c,
	// 			_addr = { ..., _M_p = 0x804c014 "192.168.0.5"}
	// 		},
	// 		<No data fields>
	// 	}
	
	return 0;
}
