LINUX.ORG.RU

История изменений

Исправление alysnix, (текущая версия) :

вот вам руст стайл на с++

///printer interface
struct i_printer {
	virtual void print() = 0;
};

///scanner interface
struct i_scanner {
	virtual void scan() = 0;
};

///printer+scanner interface
struct i_printer_scanner:	
	i_printer, 	
	i_scanner
{
};

///some concrete HP device driver
struct The_device_driver_HP {
	void hw_print(){}
	void hw_scan(){}
};

///implementation of i_printer_scanner using concrete device driver
struct PrinterScanner:
	i_printer_scanner
{
	The_device_driver_HP _driver;  ///compose
	void print() override {	_driver.hw_print(); };
	void scan() override {	_driver.hw_scan(); };
};

///printer + scanner object
i_printer_scanner* printer_scanner = new PrinterScanner;

///printing only
i_printer* printer = printer_scanner;

///scanning only
i_scanner* scanner = printer_scanner;

Исправление alysnix, :

вот вам руст стайл на с++

///printer interface
struct i_printer {
	virtual void print() = 0;
};

///scanner interface
struct i_scanner {
	virtual void scan() = 0;
};

///printer+scanner interface
struct i_printer_scanner:	
	i_printer, 	
	i_scanner
{
};

///some concrete HP device driver
struct The_device_driver_HP {
	void hw_print(){}
	void hw_scan(){}
};

///implementation of i_printer_scanner using concrete device driver
struct PrinterScanner:
	i_printer_scanner
{
	The_device_driver_HP _driver;  ///compose
	void print() override {	_driver.hw_print(); };
	void scan() override {	_driver.hw_scan(); };
};

///printer + scanner object
i_printer_scanner* printer_scanner = new PrinterScanner;

///printing only
i_printer* printer = printer_scanner;

///scanning only
i_scanner* scanner = printer_scanner;

Исходная версия alysnix, :

вот вам руст стайл на с++

///printer interface
struct i_printer {
	virtual void print() = 0;
};

///scanner interface
struct i_scanner {
	virtual void scan() = 0;
};

///printer+scanner interface
struct i_printer_scanner:	
	i_printer, 	
	i_scanner
{
};

///some concrete HP device driver
struct The_device_driver_HP {
	void hw_print(){}
	void hw_scan(){}
};

///implementation of i_printer_scanner using concrete device driver
struct PrinterScanner:
	i_printer_scanner
{
	The_device_driver_HP _driver;  ///compose
	void print() override {	_driver.hw_print(); };
	void scan() override {	_driver.hw_scan(); };
};

///printer + scanner object
i_printer_scanner* printer_scanner = new PrinterScanner;

///printing only
i_printer* printer = printer_scanner;

///scanning only
i_printer* scanner = printer_scanner;