c++ now: cpp/c++ code using utxcpp

This program uses dynamic_cast for bidirectional conversion: cast from base_class to derived_class, and cast from derived_class to base_class.

API Used:

  • utx::print (See)
  • c++ dynamic_cast (See)

Utxcpp

Download:

#include <utxcpp/core.hpp>

template <typename derived_class>
class base_class
{
public:
	virtual ~base_class() = default;
public:
	void fn() const
	{
		dynamic_cast<const derived_class &>(*this).func();
	}
public:
	void fizz() const
	{
		utx::print("base_class::fizz");
	}
};

class derived_class: public base_class<derived_class>
{
public:
	void func() const
	{
		utx::print("derived_class::func");
	}
public:
	void buzz() const
	{
		dynamic_cast<const derived_class &>(*this).fizz();
	}
};

int main()
{
	derived_class dc1;
	dc1.fn();
	base_class<derived_class> && bc1 = derived_class{};
	dynamic_cast<derived_class &>(bc1).buzz();
}

Output:

derived_class::func
base_class::fizz

Utxcpp

Utxcpp is an easy and simple to use c++ library that makes simple things simple. Utxcpp has some classes, templates and functions that can be used in sycl kernel.

Enter

Utxcpp Samples Driven

Utxcpp Samples Driven Docs

Enter

Nirtcpp

Nirtcpp is a graphics and game
engine forked irrlicht.

Enter

Logs

Logs - Record my c++ explorer

Enter

B2 Build

B2 is an easy to use and very
powerful cpp/c++ project
build system.

Enter

Utxcpp Install

Install b2 build, Install boostbook,
Install quickbook, Install Utxcpp

Enter