PrevUpHomeNext

Derived From It


Can I create a class derived from class dcpp::shared_device ?

Yes.

Although it is not designed for using as the base class of other classes, it is still inheritance friendly.

See c++ example.

c++ example

#include <duckcpp/shared.hpp>

namespace my_space
{

class my_device: virtual public dcpp::shared_device
{
private:
	using self_type = my_space::my_device;
	using base_type = dcpp::shared_device;
public:
	virtual ~my_device()
	{
	}
public:
	my_device(dcpp::uint32_kt width__, dcpp::uint32_kt height__):
		base_type{width__, height__, "My c++ application"}
	{
	}
protected:
	void my_insert_to_render()
	{
		// You can add something here, and also, you can remove this method .my_inert_to_render()
	}
public:
	void run()
	{
		while (base_type::run())
		{
			if (! this->window_active())
			{
				this->yield();
				continue;
			}
			this->scene()->drawAll();
			this->my_insert_to_render();
			this->video()->swapScenes(0xff123456);
		}
	}
};

}	// namespace my_space

int main()
{
	my_space::my_device device{2560, 1440};
	device.run();
}

Date

> date
Mon Apr  7 08:30:09 AM UTC 2025

Back

Up: Tips

c++

Duckcpp

cppfx.xyz


PrevUpHomeNext