<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.emmtrix.com/w139/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=FuzzyBot</id>
	<title>emmtrix Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://www.emmtrix.com/w139/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=FuzzyBot"/>
	<link rel="alternate" type="text/html" href="https://www.emmtrix.com/wiki/Special:Contributions/FuzzyBot"/>
	<updated>2026-04-21T00:32:44Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.10</generator>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Demystifying_C%2B%2B_-_Classes/en&amp;diff=267</id>
		<title>Demystifying C++ - Classes/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Demystifying_C%2B%2B_-_Classes/en&amp;diff=267"/>
		<updated>2023-10-30T10:33:11Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Updating to match new version of source page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;languages/&amp;gt;&lt;br /&gt;
Classes are a cornerstone of C++ programming, embodying the object-oriented paradigm, which is essential for structuring modern, complex software applications. In C++, classes encapsulate data and behavior through attributes and methods. In contrast, Assembler and C primarily rely on data structures and functions.&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
Just as the C++ compiler does, the transpiler translates classes into C structures and functions. The methods of the class are turned into functions that take a &amp;quot;this&amp;quot; pointer to the structure representing the class. When accessing attributes, the this-pointer is used automatically, and when calling other methods, it is simply passed on.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Methods&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
class C1 {&lt;br /&gt;
  int attr;&lt;br /&gt;
public:  &lt;br /&gt;
  void onChangeAttr();&lt;br /&gt;
&lt;br /&gt;
void setAttr(int v) {&lt;br /&gt;
    attr = v;&lt;br /&gt;
    onChangeAttr();&lt;br /&gt;
  }&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
struct C1 {&lt;br /&gt;
  int attr;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
void C1_onChangeAttr(struct C1* this);&lt;br /&gt;
&lt;br /&gt;
void C1_setAttr(struct C1* this, int v) {&lt;br /&gt;
  this-&amp;gt;attr = v;&lt;br /&gt;
  C1_onChangeAttr(this);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Inheritance===&lt;br /&gt;
&lt;br /&gt;
In C++, inheritance is a central principle that allows classes to inherit attributes and methods from base classes. However, C does not naturally support inheritance. Therefore, the C++ to C transpiler uses special techniques to simulate inheritance relationships by embedding each base class as its own field in the derived structure.&lt;br /&gt;
&lt;br /&gt;
A crucial aspect of inheritance is the casting between base classes (Base) and derived classes (Derived):&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Derived-to-Base Casts&#039;&#039;&#039;: In assembler, such a cast corresponds to an addition with a constant value. These are relatively simple to implement in C by accessing the respective field in the derived structure. This happens implicitly in C++ in many places, such as when calling base class methods or accessing attributes.&lt;br /&gt;
*&#039;&#039;&#039;Static Base-to-Derived Casts&#039;&#039;&#039;: In assembler, such a cast corresponds to a subtraction with a constant value. This is more complex in C and requires some C casting.&lt;br /&gt;
*&#039;&#039;&#039;Dynamic Base-to-Derived Casts&#039;&#039;&#039;: These are produced with the &amp;lt;code&amp;gt;dynamic_cast&amp;lt;/code&amp;gt; keyword and are more complex in implementation since they require type checking at runtime. Dynamic casts will be discussed in the chapter on virtual classes.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Representation of Base Classes&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
class Derived : public Base1, public Base2 {&lt;br /&gt;
  ...&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
struct Derived {&lt;br /&gt;
  struct Base1 base1;&lt;br /&gt;
  struct Base2 base2;&lt;br /&gt;
&lt;br /&gt;
  ...&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!Derived-to-Base Cast&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
static_cast&amp;lt;Base2*&amp;gt;(derived)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;derived-&amp;gt;base2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!Static Base-To-Derived Cast&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
static_cast&amp;lt;Derived*&amp;gt;(base2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
(Derived*)((char*)base2 - offsetof(Derived, base2))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Constructors and Destructors===&lt;br /&gt;
Constructors and destructors play a pivotal role in C++ programming as they manage automatic initialization and cleanup processes for objects. Constructors are special class methods that are automatically invoked when an object is created. They&#039;re often used to define initial values for object attributes and perform other initialization tasks. Destructors are the opposite of constructors; they&#039;re invoked when an object is destroyed and are ideal for cleanup tasks like releasing memory and other resources.&lt;br /&gt;
&lt;br /&gt;
In C, there&#039;s no direct counterpart for constructors and destructors. Instead, they are replaced by regular functions that are called upon object creation or destruction. For completeness, it should be mentioned that for the Itanium ABI, at least two constructor functions (&amp;lt;code&amp;gt;ctor_complete&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ctor_base&amp;lt;/code&amp;gt;) and destructor functions (&amp;lt;code&amp;gt;dtor_complete&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;dtor_base&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;dtor_delete&amp;lt;/code&amp;gt;) are generated. The complete variants are typically used, base variants are required for base classes in the constructor/destructor, and &amp;lt;code&amp;gt;dtor_delete&amp;lt;/code&amp;gt; is used when applying delete to a class with a virtual destructor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:15--&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Constructors&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
class C1 {&lt;br /&gt;
  // Attributes&lt;br /&gt;
public:&lt;br /&gt;
  C1() {&lt;br /&gt;
    // Initialization code&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  ~C1() {&lt;br /&gt;
    // Cleanup code&lt;br /&gt;
  }&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
struct C1 {&lt;br /&gt;
  // Attributes&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
void C1_ctor_complete(struct C1* this) {&lt;br /&gt;
  // Initialization code&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void C1_dtor_complete(struct C1* this) {&lt;br /&gt;
  // Cleanup code&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!Stack Variables&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  C1 obj;&lt;br /&gt;
&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  struct C1 obj;&lt;br /&gt;
  C1_ctor_complete(&amp;amp;obj);&lt;br /&gt;
&lt;br /&gt;
  ...&lt;br /&gt;
&lt;br /&gt;
  C1_dtor_complete(&amp;amp;obj);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[Category:Demystifying C++|Classes]]&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Demystifying_C%2B%2B_-_Classes/ja&amp;diff=266</id>
		<title>Demystifying C++ - Classes/ja</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Demystifying_C%2B%2B_-_Classes/ja&amp;diff=266"/>
		<updated>2023-10-30T10:33:10Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Updating to match new version of source page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;languages/&amp;gt;&lt;br /&gt;
クラスはC++プログラミングの基石であり、現代の複雑なソフトウェアアプリケーションの構造化に不可欠なオブジェクト指向パラダイムを体現しています。C++では、クラスは属性とメソッドを通じてデータと振る舞いをカプセル化します。対照的に、アセンブラやCは主にデータ構造と関数に依存しています。&lt;br /&gt;
&lt;br /&gt;
===メソッド===&lt;br /&gt;
C++コンパイラと同様に、トランスパイラはクラスをCの構造体と関数に変換します。クラスのメソッドは、クラスを表す構造体への&amp;quot;this&amp;quot;ポインタを取る関数に変換されます。属性にアクセスする際には、thisポインタが自動的に使用され、他のメソッドを呼び出す際には、それが単に渡されます。&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!メソッド&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
class C1 {&lt;br /&gt;
  int attr;&lt;br /&gt;
public:  &lt;br /&gt;
  void onChangeAttr();&lt;br /&gt;
&lt;br /&gt;
void setAttr(int v) {&lt;br /&gt;
    attr = v;&lt;br /&gt;
    onChangeAttr();&lt;br /&gt;
  }&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
struct C1 {&lt;br /&gt;
  int attr;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
void C1_onChangeAttr(struct C1* this);&lt;br /&gt;
&lt;br /&gt;
void C1_setAttr(struct C1* this, int v) {&lt;br /&gt;
  this-&amp;gt;attr = v;&lt;br /&gt;
  C1_onChangeAttr(this);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===継承===&lt;br /&gt;
&lt;br /&gt;
C++では、継承はクラスが基底クラスから属性やメソッドを継承することを可能にする中心的な原則です。しかし、Cは自然に継承をサポートしていません。そのため、C++からCへのトランスパイラは、派生構造体の各基底クラスをその独自のフィールドとして埋め込むことで、継承関係をシミュレートする特別な技術を使用します。&lt;br /&gt;
&lt;br /&gt;
継承の重要な側面は、基底クラス（Base）と派生クラス（Derived）間のキャスティングです：&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;派生クラスから基底クラスへのキャスト&#039;&#039;&#039;: アセンブラでは、このようなキャストは定数値の加算に対応します。これは、派生構造体の該当するフィールドにアクセスすることでCで比較的簡単に実装できます。これは、基底クラスのメソッドを呼び出す場合や属性にアクセスする場合など、C++の多くの場所で暗黙的に発生します。&lt;br /&gt;
*&#039;&#039;&#039;静的な基底クラスから派生クラスへのキャスト&#039;&#039;&#039;: アセンブラでは、このようなキャストは定数値の減算に対応します。これはCでより複雑であり、いくつかのCキャスティングが必要です。&lt;br /&gt;
*&#039;&#039;&#039;動的な基底クラスから派生クラスへのキャスト&#039;&#039;&#039;: これらは&amp;lt;code&amp;gt;dynamic_cast&amp;lt;/code&amp;gt;キーワードで生成され、実装がより複雑です。これはランタイム時の型チェックが必要です。動的キャストについては、仮想クラスに関する章で議論されます。&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!基底クラスの表現&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
class Derived : public Base1, public Base2 {&lt;br /&gt;
  ...&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
struct Derived {&lt;br /&gt;
  struct Base1 base1;&lt;br /&gt;
  struct Base2 base2;&lt;br /&gt;
&lt;br /&gt;
  ...&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!派生クラスから基底クラスへのキャスト&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
static_cast&amp;lt;Base2*&amp;gt;(derived)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;derived-&amp;gt;base2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!静的な基底クラスから派生クラスへのキャスト&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
static_cast&amp;lt;Derived*&amp;gt;(base2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
(Derived*)((char*)base2 - offsetof(Derived, base2))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===コンストラクタとデストラクタ===&lt;br /&gt;
コンストラクタとデストラクタは、オブジェクトの自動初期化とクリーンアッププロセスを管理するため、C++プログラミングにおいて中心的な役割を果たします。コンストラクタはオブジェクトが作成されるときに自動的に呼び出される特別なクラスメソッドです。オブジェクト属性の初期値を定義したり、他の初期化タスクを実行するためによく使用されます。デストラクタはコンストラクタの反対であり、オブジェクトが破棄されるときに呼び出され、メモリや他のリソースを解放するようなクリーンアップタスクに最適です。&lt;br /&gt;
&lt;br /&gt;
Cでは、コンストラクタとデストラクタの直接的な対応物はありません。代わりに、オブジェクトの作成や破棄時に呼び出される通常の関数に置き換えられます。完全性のために、Itanium ABIには、少なくとも2つのコンストラクタ関数（&amp;lt;code&amp;gt;ctor_complete&amp;lt;/code&amp;gt;、&amp;lt;code&amp;gt;ctor_base&amp;lt;/code&amp;gt;）およびデストラクタ関数（&amp;lt;code&amp;gt;dtor_complete&amp;lt;/code&amp;gt;、&amp;lt;code&amp;gt;dtor_base&amp;lt;/code&amp;gt;、&amp;lt;code&amp;gt;dtor_delete&amp;lt;/code&amp;gt;）が生成されることを述べておくべきです。completeバリアントは通常使用され、baseバリアントはコンストラクタ/デストラクタ内の基底クラスに必要であり、&amp;lt;code&amp;gt;dtor_delete&amp;lt;/code&amp;gt;は仮想デストラクタを持つクラスにdeleteを適用するときに使用されます。&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:15--&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!コンストラクタ&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
class C1 {&lt;br /&gt;
  // Attributes&lt;br /&gt;
public:&lt;br /&gt;
  C1() {&lt;br /&gt;
    // Initialization code&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  ~C1() {&lt;br /&gt;
    // Cleanup code&lt;br /&gt;
  }&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
struct C1 {&lt;br /&gt;
  // Attributes&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
void C1_ctor_complete(struct C1* this) {&lt;br /&gt;
  // Initialization code&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void C1_dtor_complete(struct C1* this) {&lt;br /&gt;
  // Cleanup code&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!スタック変数&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  C1 obj;&lt;br /&gt;
&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  struct C1 obj;&lt;br /&gt;
  C1_ctor_complete(&amp;amp;obj);&lt;br /&gt;
&lt;br /&gt;
  ...&lt;br /&gt;
&lt;br /&gt;
  C1_dtor_complete(&amp;amp;obj);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[Category:Demystifying C++|Classes]]&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Category:Demystifying_C%2B%2B/en&amp;diff=264</id>
		<title>Category:Demystifying C++/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Category:Demystifying_C%2B%2B/en&amp;diff=264"/>
		<updated>2023-10-30T10:24:01Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Updating to match new version of source page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:C++ to C Compiler]]&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Demystifying_C%2B%2B_-_Classes/en&amp;diff=253</id>
		<title>Demystifying C++ - Classes/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Demystifying_C%2B%2B_-_Classes/en&amp;diff=253"/>
		<updated>2023-10-30T10:17:54Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Updating to match new version of source page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;languages/&amp;gt;&lt;br /&gt;
Classes are a cornerstone of C++ programming, embodying the object-oriented paradigm, which is essential for structuring modern, complex software applications. In C++, classes encapsulate data and behavior through attributes and methods. In contrast, Assembler and C primarily rely on data structures and functions.&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
Just as the C++ compiler does, the transpiler translates classes into C structures and functions. The methods of the class are turned into functions that take a &amp;quot;this&amp;quot; pointer to the structure representing the class. When accessing attributes, the this-pointer is used automatically, and when calling other methods, it is simply passed on.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Methods&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
class C1 {&lt;br /&gt;
  int attr;&lt;br /&gt;
public:  &lt;br /&gt;
  void onChangeAttr();&lt;br /&gt;
&lt;br /&gt;
void setAttr(int v) {&lt;br /&gt;
    attr = v;&lt;br /&gt;
    onChangeAttr();&lt;br /&gt;
  }&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
struct C1 {&lt;br /&gt;
  int attr;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
void C1_onChangeAttr(struct C1* this);&lt;br /&gt;
&lt;br /&gt;
void C1_setAttr(struct C1* this, int v) {&lt;br /&gt;
  this-&amp;gt;attr = v;&lt;br /&gt;
  C1_onChangeAttr(this);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Inheritance===&lt;br /&gt;
&lt;br /&gt;
In C++, inheritance is a central principle that allows classes to inherit attributes and methods from base classes. However, C does not naturally support inheritance. Therefore, the C++ to C transpiler uses special techniques to simulate inheritance relationships by embedding each base class as its own field in the derived structure.&lt;br /&gt;
&lt;br /&gt;
A crucial aspect of inheritance is the casting between base classes (Base) and derived classes (Derived):&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Derived-to-Base Casts&#039;&#039;&#039;: In assembler, such a cast corresponds to an addition with a constant value. These are relatively simple to implement in C by accessing the respective field in the derived structure. This happens implicitly in C++ in many places, such as when calling base class methods or accessing attributes.&lt;br /&gt;
*&#039;&#039;&#039;Static Base-to-Derived Casts&#039;&#039;&#039;: In assembler, such a cast corresponds to a subtraction with a constant value. This is more complex in C and requires some C casting.&lt;br /&gt;
*&#039;&#039;&#039;Dynamic Base-to-Derived Casts&#039;&#039;&#039;: These are produced with the &amp;lt;code&amp;gt;dynamic_cast&amp;lt;/code&amp;gt; keyword and are more complex in implementation since they require type checking at runtime. Dynamic casts will be discussed in the chapter on virtual classes.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Representation of Base Classes&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
class Derived : public Base1, public Base2 {&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
struct Derived {&lt;br /&gt;
  struct Base1 base1;&lt;br /&gt;
  struct Base2 base2;&lt;br /&gt;
&lt;br /&gt;
  ...&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!Derived-to-Base Cast&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
static_cast&amp;lt;Base2*&amp;gt;(derived)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;derived-&amp;gt;base2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!Static Base-To-Derived Cast&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
static_cast&amp;lt;Derived*&amp;gt;(base2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
(Derived*)((char*)base2 - offsetof(Derived, base2))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Constructors and Destructors===&lt;br /&gt;
Constructors and destructors play a pivotal role in C++ programming as they manage automatic initialization and cleanup processes for objects. Constructors are special class methods that are automatically invoked when an object is created. They&#039;re often used to define initial values for object attributes and perform other initialization tasks. Destructors are the opposite of constructors; they&#039;re invoked when an object is destroyed and are ideal for cleanup tasks like releasing memory and other resources.&lt;br /&gt;
&lt;br /&gt;
In C, there&#039;s no direct counterpart for constructors and destructors. Instead, they are replaced by regular functions that are called upon object creation or destruction. For completeness, it should be mentioned that for the Itanium ABI, at least two constructor functions (&amp;lt;code&amp;gt;ctor_complete&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ctor_base&amp;lt;/code&amp;gt;) and destructor functions (&amp;lt;code&amp;gt;dtor_complete&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;dtor_base&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;dtor_delete&amp;lt;/code&amp;gt;) are generated. The complete variants are typically used, base variants are required for base classes in the constructor/destructor, and &amp;lt;code&amp;gt;dtor_delete&amp;lt;/code&amp;gt; is used when applying delete to a class with a virtual destructor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:15--&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Constructors&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
class C1 {&lt;br /&gt;
  // Attributes&lt;br /&gt;
public:&lt;br /&gt;
  C1() {&lt;br /&gt;
    // Initialization code&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  ~C1() {&lt;br /&gt;
    // Cleanup code&lt;br /&gt;
  }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:17--&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
struct C1 {&lt;br /&gt;
  // Attributes&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
void C1_ctor_complete(struct C1* this) {&lt;br /&gt;
  // Initialization code&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void C1_dtor_complete(struct C1* this) {&lt;br /&gt;
  // Cleanup code&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!Stack Variables&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  C1 obj;&lt;br /&gt;
&lt;br /&gt;
  ...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:21--&amp;gt;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  struct C1 obj;&lt;br /&gt;
  C1_ctor_complete(&amp;amp;obj);&lt;br /&gt;
&lt;br /&gt;
  ...&lt;br /&gt;
&lt;br /&gt;
  C1_dtor_complete(&amp;amp;obj);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[Category:Demystifying C++|Classes]]&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/29/en&amp;diff=252</id>
		<title>Translations:Demystifying C++ - Classes/29/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/29/en&amp;diff=252"/>
		<updated>2023-10-30T10:17:52Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Importing a new version from external source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Stack Variables&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/28/en&amp;diff=251</id>
		<title>Translations:Demystifying C++ - Classes/28/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/28/en&amp;diff=251"/>
		<updated>2023-10-30T10:17:52Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Importing a new version from external source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Constructors&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/27/en&amp;diff=250</id>
		<title>Translations:Demystifying C++ - Classes/27/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/27/en&amp;diff=250"/>
		<updated>2023-10-30T10:17:52Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Importing a new version from external source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Static Base-To-Derived Cast&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/26/en&amp;diff=249</id>
		<title>Translations:Demystifying C++ - Classes/26/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/26/en&amp;diff=249"/>
		<updated>2023-10-30T10:17:52Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Importing a new version from external source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Derived-to-Base Cast&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/25/en&amp;diff=248</id>
		<title>Translations:Demystifying C++ - Classes/25/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/25/en&amp;diff=248"/>
		<updated>2023-10-30T10:17:52Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Importing a new version from external source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Representation of Base Classes&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Demystifying_C%2B%2B_-_Classes/ja&amp;diff=226</id>
		<title>Demystifying C++ - Classes/ja</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Demystifying_C%2B%2B_-_Classes/ja&amp;diff=226"/>
		<updated>2023-10-30T10:08:42Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Updating to match new version of source page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;languages/&amp;gt;&lt;br /&gt;
クラスはC++プログラミングの基石であり、現代の複雑なソフトウェアアプリケーションの構造化に不可欠なオブジェクト指向パラダイムを体現しています。C++では、クラスは属性とメソッドを通じてデータと振る舞いをカプセル化します。対照的に、アセンブラやCは主にデータ構造と関数に依存しています。&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-translate-fuzzy&amp;quot;&amp;gt;&lt;br /&gt;
===メソッド===&lt;br /&gt;
C++コンパイラと同様に、トランスパイラはクラスをCの構造体と関数に変換します。クラスのメソッドは、クラスを表す構造体への&amp;quot;this&amp;quot;ポインタを取る関数に変換されます。属性にアクセスする際には、thisポインタが自動的に使用され、他のメソッドを呼び出す際には、それが単に渡されます。&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!メソッド&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
class C1 {&lt;br /&gt;
  int attr;&lt;br /&gt;
public:  &lt;br /&gt;
  void onChangeAttr();&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Methods&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
class C1 {&lt;br /&gt;
  int attr;&lt;br /&gt;
public:  &lt;br /&gt;
  void onChangeAttr();&lt;br /&gt;
&lt;br /&gt;
void setAttr(int v) {&lt;br /&gt;
    attr = v;&lt;br /&gt;
    onChangeAttr();&lt;br /&gt;
  }&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
struct C1 {&lt;br /&gt;
  int attr;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
void C1_onChangeAttr(struct C1* this);&lt;br /&gt;
&lt;br /&gt;
void C1_setAttr(struct C1* this, int v) {&lt;br /&gt;
  this-&amp;gt;attr = v;&lt;br /&gt;
  C1_onChangeAttr(this);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Inheritance===&lt;br /&gt;
&lt;br /&gt;
In C++, inheritance is a central principle that allows classes to inherit attributes and methods from base classes. However, C does not naturally support inheritance. Therefore, the C++ to C transpiler uses special techniques to simulate inheritance relationships by embedding each base class as its own field in the derived structure.&lt;br /&gt;
&lt;br /&gt;
A crucial aspect of inheritance is the casting between base classes (Base) and derived classes (Derived):&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Derived-to-Base Casts&#039;&#039;&#039;: In assembler, such a cast corresponds to an addition with a constant value. These are relatively simple to implement in C by accessing the respective field in the derived structure. This happens implicitly in C++ in many places, such as when calling base class methods or accessing attributes.&lt;br /&gt;
*&#039;&#039;&#039;Static Base-to-Derived Casts&#039;&#039;&#039;: In assembler, such a cast corresponds to a subtraction with a constant value. This is more complex in C and requires some C casting.&lt;br /&gt;
*&#039;&#039;&#039;Dynamic Base-to-Derived Casts&#039;&#039;&#039;: These are produced with the &amp;lt;code&amp;gt;dynamic_cast&amp;lt;/code&amp;gt; keyword and are more complex in implementation since they require type checking at runtime. Dynamic casts will be discussed in the chapter on virtual classes.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Representation of Base Classes&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
class Derived : public Base1, public Base2 {&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
struct Derived {&lt;br /&gt;
  struct Base1 base1;&lt;br /&gt;
  struct Base2 base2;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--T:12--&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!Derived-to-Base Cast&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
static_cast&amp;lt;Base2*&amp;gt;(derived)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;derived-&amp;gt;base2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!Static Base-To-Derived Cast&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
static_cast&amp;lt;Derived*&amp;gt;(base2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
(Derived*)((char*)base2 - offsetof(Derived, base2))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Constructors and Destructors===&lt;br /&gt;
Constructors and destructors play a pivotal role in C++ programming as they manage automatic initialization and cleanup processes for objects. Constructors are special class methods that are automatically invoked when an object is created. They&#039;re often used to define initial values for object attributes and perform other initialization tasks. Destructors are the opposite of constructors; they&#039;re invoked when an object is destroyed and are ideal for cleanup tasks like releasing memory and other resources.&lt;br /&gt;
&lt;br /&gt;
In C, there&#039;s no direct counterpart for constructors and destructors. Instead, they are replaced by regular functions that are called upon object creation or destruction. For completeness, it should be mentioned that for the Itanium ABI, at least two constructor functions (&amp;lt;code&amp;gt;ctor_complete&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ctor_base&amp;lt;/code&amp;gt;) and destructor functions (&amp;lt;code&amp;gt;dtor_complete&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;dtor_base&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;dtor_delete&amp;lt;/code&amp;gt;) are generated. The complete variants are typically used, base variants are required for base classes in the constructor/destructor, and &amp;lt;code&amp;gt;dtor_delete&amp;lt;/code&amp;gt; is used when applying delete to a class with a virtual destructor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:15--&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Constructors&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
class C1 {&lt;br /&gt;
  // Attributes&lt;br /&gt;
public:&lt;br /&gt;
  C1() {&lt;br /&gt;
    // Initialization code&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--T:16--&amp;gt;&lt;br /&gt;
~C1() {&lt;br /&gt;
    // Cleanup code&lt;br /&gt;
  }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:17--&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
struct C1 {&lt;br /&gt;
  // Attributes&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:18--&amp;gt;&lt;br /&gt;
void C1_ctor_complete(struct C1* this) {&lt;br /&gt;
  // Initialization code&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:19--&amp;gt;&lt;br /&gt;
void C1_dtor_complete(struct C1* this) {&lt;br /&gt;
  // Cleanup code&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!Stack Variables&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  C1 obj;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--T:20--&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:21--&amp;gt;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  struct C1 obj;&lt;br /&gt;
  C1_ctor_complete(&amp;amp;obj);&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--T:22--&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--T:23--&amp;gt;&lt;br /&gt;
C1_dtor_complete(&amp;amp;obj);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[Category:Demystifying C++|Classes]]&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Demystifying_C%2B%2B_-_Classes/en&amp;diff=225</id>
		<title>Demystifying C++ - Classes/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Demystifying_C%2B%2B_-_Classes/en&amp;diff=225"/>
		<updated>2023-10-30T10:08:42Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Updating to match new version of source page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;languages/&amp;gt;&lt;br /&gt;
Classes are a cornerstone of C++ programming, embodying the object-oriented paradigm, which is essential for structuring modern, complex software applications. In C++, classes encapsulate data and behavior through attributes and methods. In contrast, Assembler and C primarily rely on data structures and functions.&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
Just as the C++ compiler does, the transpiler translates classes into C structures and functions. The methods of the class are turned into functions that take a &amp;quot;this&amp;quot; pointer to the structure representing the class. When accessing attributes, the this-pointer is used automatically, and when calling other methods, it is simply passed on.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Methods&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
class C1 {&lt;br /&gt;
  int attr;&lt;br /&gt;
public:  &lt;br /&gt;
  void onChangeAttr();&lt;br /&gt;
&lt;br /&gt;
void setAttr(int v) {&lt;br /&gt;
    attr = v;&lt;br /&gt;
    onChangeAttr();&lt;br /&gt;
  }&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
struct C1 {&lt;br /&gt;
  int attr;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
void C1_onChangeAttr(struct C1* this);&lt;br /&gt;
&lt;br /&gt;
void C1_setAttr(struct C1* this, int v) {&lt;br /&gt;
  this-&amp;gt;attr = v;&lt;br /&gt;
  C1_onChangeAttr(this);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Inheritance===&lt;br /&gt;
&lt;br /&gt;
In C++, inheritance is a central principle that allows classes to inherit attributes and methods from base classes. However, C does not naturally support inheritance. Therefore, the C++ to C transpiler uses special techniques to simulate inheritance relationships by embedding each base class as its own field in the derived structure.&lt;br /&gt;
&lt;br /&gt;
A crucial aspect of inheritance is the casting between base classes (Base) and derived classes (Derived):&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Derived-to-Base Casts&#039;&#039;&#039;: In assembler, such a cast corresponds to an addition with a constant value. These are relatively simple to implement in C by accessing the respective field in the derived structure. This happens implicitly in C++ in many places, such as when calling base class methods or accessing attributes.&lt;br /&gt;
*&#039;&#039;&#039;Static Base-to-Derived Casts&#039;&#039;&#039;: In assembler, such a cast corresponds to a subtraction with a constant value. This is more complex in C and requires some C casting.&lt;br /&gt;
*&#039;&#039;&#039;Dynamic Base-to-Derived Casts&#039;&#039;&#039;: These are produced with the &amp;lt;code&amp;gt;dynamic_cast&amp;lt;/code&amp;gt; keyword and are more complex in implementation since they require type checking at runtime. Dynamic casts will be discussed in the chapter on virtual classes.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Representation of Base Classes&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
class Derived : public Base1, public Base2 {&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
struct Derived {&lt;br /&gt;
  struct Base1 base1;&lt;br /&gt;
  struct Base2 base2;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--T:12--&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!Derived-to-Base Cast&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
static_cast&amp;lt;Base2*&amp;gt;(derived)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;derived-&amp;gt;base2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!Static Base-To-Derived Cast&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
static_cast&amp;lt;Derived*&amp;gt;(base2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
(Derived*)((char*)base2 - offsetof(Derived, base2))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Constructors and Destructors===&lt;br /&gt;
Constructors and destructors play a pivotal role in C++ programming as they manage automatic initialization and cleanup processes for objects. Constructors are special class methods that are automatically invoked when an object is created. They&#039;re often used to define initial values for object attributes and perform other initialization tasks. Destructors are the opposite of constructors; they&#039;re invoked when an object is destroyed and are ideal for cleanup tasks like releasing memory and other resources.&lt;br /&gt;
&lt;br /&gt;
In C, there&#039;s no direct counterpart for constructors and destructors. Instead, they are replaced by regular functions that are called upon object creation or destruction. For completeness, it should be mentioned that for the Itanium ABI, at least two constructor functions (&amp;lt;code&amp;gt;ctor_complete&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ctor_base&amp;lt;/code&amp;gt;) and destructor functions (&amp;lt;code&amp;gt;dtor_complete&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;dtor_base&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;dtor_delete&amp;lt;/code&amp;gt;) are generated. The complete variants are typically used, base variants are required for base classes in the constructor/destructor, and &amp;lt;code&amp;gt;dtor_delete&amp;lt;/code&amp;gt; is used when applying delete to a class with a virtual destructor.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:15--&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Constructors&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
class C1 {&lt;br /&gt;
  // Attributes&lt;br /&gt;
public:&lt;br /&gt;
  C1() {&lt;br /&gt;
    // Initialization code&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--T:16--&amp;gt;&lt;br /&gt;
~C1() {&lt;br /&gt;
    // Cleanup code&lt;br /&gt;
  }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:17--&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
struct C1 {&lt;br /&gt;
  // Attributes&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:18--&amp;gt;&lt;br /&gt;
void C1_ctor_complete(struct C1* this) {&lt;br /&gt;
  // Initialization code&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:19--&amp;gt;&lt;br /&gt;
void C1_dtor_complete(struct C1* this) {&lt;br /&gt;
  // Cleanup code&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!Stack Variables&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  C1 obj;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--T:20--&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:21--&amp;gt;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  struct C1 obj;&lt;br /&gt;
  C1_ctor_complete(&amp;amp;obj);&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--T:22--&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!--T:23--&amp;gt;&lt;br /&gt;
C1_dtor_complete(&amp;amp;obj);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[Category:Demystifying C++|Classes]]&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/24/en&amp;diff=224</id>
		<title>Translations:Demystifying C++ - Classes/24/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/24/en&amp;diff=224"/>
		<updated>2023-10-30T10:08:41Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Importing a new version from external source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Methods&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/2/en&amp;diff=223</id>
		<title>Translations:Demystifying C++ - Classes/2/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/2/en&amp;diff=223"/>
		<updated>2023-10-30T10:08:41Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Importing a new version from external source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Methods===&lt;br /&gt;
Just as the C++ compiler does, the transpiler translates classes into C structures and functions. The methods of the class are turned into functions that take a &amp;quot;this&amp;quot; pointer to the structure representing the class. When accessing attributes, the this-pointer is used automatically, and when calling other methods, it is simply passed on.&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Demystifying_C%2B%2B_-_Classes/en&amp;diff=215</id>
		<title>Demystifying C++ - Classes/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Demystifying_C%2B%2B_-_Classes/en&amp;diff=215"/>
		<updated>2023-10-30T10:02:35Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Updating to match new version of source page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;languages/&amp;gt;&lt;br /&gt;
Classes are a cornerstone of C++ programming, embodying the object-oriented paradigm, which is essential for structuring modern, complex software applications. In C++, classes encapsulate data and behavior through attributes and methods. In contrast, Assembler and C primarily rely on data structures and functions.&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
Just as the C++ compiler does, the transpiler translates classes into C structures and functions. The methods of the class are turned into functions that take a &amp;quot;this&amp;quot; pointer to the structure representing the class. When accessing attributes, the this-pointer is used automatically, and when calling other methods, it is simply passed on.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Methods&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
class C1 {&lt;br /&gt;
  int attr;&lt;br /&gt;
public:  &lt;br /&gt;
  void onChangeAttr();&lt;br /&gt;
&lt;br /&gt;
  void setAttr(int v) {&lt;br /&gt;
    attr = v;&lt;br /&gt;
    onChangeAttr();&lt;br /&gt;
  }&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
struct C1 {&lt;br /&gt;
  int attr;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
void C1_onChangeAttr(struct C1* this);&lt;br /&gt;
&lt;br /&gt;
void C1_setAttr(struct C1* this, int v) {&lt;br /&gt;
  this-&amp;gt;attr = v;&lt;br /&gt;
  C1_onChangeAttr(this);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Inheritance===&lt;br /&gt;
&lt;br /&gt;
In C++, inheritance is a central principle that allows classes to inherit attributes and methods from base classes. However, C does not naturally support inheritance. Therefore, the C++ to C transpiler uses special techniques to simulate inheritance relationships by embedding each base class as its own field in the derived structure.&lt;br /&gt;
&lt;br /&gt;
A crucial aspect of inheritance is the casting between base classes (Base) and derived classes (Derived):&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Derived-to-Base Casts&#039;&#039;&#039;: In assembler, such a cast corresponds to an addition with a constant value. These are relatively simple to implement in C by accessing the respective field in the derived structure. This happens implicitly in C++ in many places, such as when calling base class methods or accessing attributes.&lt;br /&gt;
*&#039;&#039;&#039;Static Base-to-Derived Casts&#039;&#039;&#039;: In assembler, such a cast corresponds to a subtraction with a constant value. This is more complex in C and requires some C casting.&lt;br /&gt;
*&#039;&#039;&#039;Dynamic Base-to-Derived Casts&#039;&#039;&#039;: These are produced with the &amp;lt;code&amp;gt;dynamic_cast&amp;lt;/code&amp;gt; keyword and are more complex in implementation since they require type checking at runtime. Dynamic casts will be discussed in the chapter on virtual classes.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Representation of Base Classes&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
class Derived : public Base1, public Base2 {&lt;br /&gt;
&lt;br /&gt;
  ...&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
struct Derived {&lt;br /&gt;
  struct Base1 base1;&lt;br /&gt;
  struct Base2 base2;&lt;br /&gt;
&lt;br /&gt;
  ...&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!Derived-to-Base Cast&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
static_cast&amp;lt;Base2*&amp;gt;(derived)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;derived-&amp;gt;base2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!Static Base-To-Derived Cast&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
static_cast&amp;lt;Derived*&amp;gt;(base2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
(Derived*)((char*)base2 - offsetof(Derived, base2))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Constructors and Destructors===&lt;br /&gt;
Constructors and destructors play a pivotal role in C++ programming as they manage automatic initialization and cleanup processes for objects. Constructors are special class methods that are automatically invoked when an object is created. They&#039;re often used to define initial values for object attributes and perform other initialization tasks. Destructors are the opposite of constructors; they&#039;re invoked when an object is destroyed and are ideal for cleanup tasks like releasing memory and other resources.&lt;br /&gt;
&lt;br /&gt;
In C, there&#039;s no direct counterpart for constructors and destructors. Instead, they are replaced by regular functions that are called upon object creation or destruction. For completeness, it should be mentioned that for the Itanium ABI, at least two constructor functions (&amp;lt;code&amp;gt;ctor_complete&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ctor_base&amp;lt;/code&amp;gt;) and destructor functions (&amp;lt;code&amp;gt;dtor_complete&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;dtor_base&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;dtor_delete&amp;lt;/code&amp;gt;) are generated. The complete variants are typically used, base variants are required for base classes in the constructor/destructor, and &amp;lt;code&amp;gt;dtor_delete&amp;lt;/code&amp;gt; is used when applying delete to a class with a virtual destructor.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Constructors&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
class C1 {&lt;br /&gt;
  // Attributes&lt;br /&gt;
public:&lt;br /&gt;
  C1() {&lt;br /&gt;
    // Initialization code&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  ~C1() {&lt;br /&gt;
    // Cleanup code&lt;br /&gt;
  }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
struct C1 {&lt;br /&gt;
  // Attributes&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
void C1_ctor_complete(struct C1* this) {&lt;br /&gt;
  // Initialization code&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void C1_dtor_complete(struct C1* this) {&lt;br /&gt;
  // Cleanup code&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!Stack Variables&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  C1 obj;&lt;br /&gt;
&lt;br /&gt;
  ...&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  struct C1 obj;&lt;br /&gt;
  C1_ctor_complete(&amp;amp;obj);&lt;br /&gt;
&lt;br /&gt;
  ...&lt;br /&gt;
&lt;br /&gt;
  C1_dtor_complete(&amp;amp;obj);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[Category:Demystifying C++|Classes]]&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/23/en&amp;diff=214</id>
		<title>Translations:Demystifying C++ - Classes/23/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/23/en&amp;diff=214"/>
		<updated>2023-10-30T10:02:33Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Importing a new version from external source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;C1_dtor_complete(&amp;amp;obj);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/22/en&amp;diff=213</id>
		<title>Translations:Demystifying C++ - Classes/22/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/22/en&amp;diff=213"/>
		<updated>2023-10-30T10:02:33Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Importing a new version from external source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;...&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/21/en&amp;diff=212</id>
		<title>Translations:Demystifying C++ - Classes/21/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/21/en&amp;diff=212"/>
		<updated>2023-10-30T10:02:33Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Importing a new version from external source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  struct C1 obj;&lt;br /&gt;
  C1_ctor_complete(&amp;amp;obj);&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/20/en&amp;diff=211</id>
		<title>Translations:Demystifying C++ - Classes/20/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/20/en&amp;diff=211"/>
		<updated>2023-10-30T10:02:33Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Importing a new version from external source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;...&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/19/en&amp;diff=210</id>
		<title>Translations:Demystifying C++ - Classes/19/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/19/en&amp;diff=210"/>
		<updated>2023-10-30T10:02:33Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Importing a new version from external source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;void C1_dtor_complete(struct C1* this) {&lt;br /&gt;
  // Cleanup code&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!Stack Variables&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  C1 obj;&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/18/en&amp;diff=209</id>
		<title>Translations:Demystifying C++ - Classes/18/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/18/en&amp;diff=209"/>
		<updated>2023-10-30T10:02:33Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Importing a new version from external source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;void C1_ctor_complete(struct C1* this) {&lt;br /&gt;
  // Initialization code&lt;br /&gt;
}&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/17/en&amp;diff=208</id>
		<title>Translations:Demystifying C++ - Classes/17/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/17/en&amp;diff=208"/>
		<updated>2023-10-30T10:02:33Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Importing a new version from external source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
struct C1 {&lt;br /&gt;
  // Attributes&lt;br /&gt;
};&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/16/en&amp;diff=207</id>
		<title>Translations:Demystifying C++ - Classes/16/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/16/en&amp;diff=207"/>
		<updated>2023-10-30T10:02:33Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Importing a new version from external source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;~C1() {&lt;br /&gt;
    // Cleanup code&lt;br /&gt;
  }&lt;br /&gt;
};&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/15/en&amp;diff=206</id>
		<title>Translations:Demystifying C++ - Classes/15/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/15/en&amp;diff=206"/>
		<updated>2023-10-30T10:02:33Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Importing a new version from external source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Constructors&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
class C1 {&lt;br /&gt;
  // Attributes&lt;br /&gt;
public:&lt;br /&gt;
  C1() {&lt;br /&gt;
    // Initialization code&lt;br /&gt;
  }&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/14/en&amp;diff=205</id>
		<title>Translations:Demystifying C++ - Classes/14/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/14/en&amp;diff=205"/>
		<updated>2023-10-30T10:02:33Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Importing a new version from external source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In C, there&#039;s no direct counterpart for constructors and destructors. Instead, they are replaced by regular functions that are called upon object creation or destruction. For completeness, it should be mentioned that for the Itanium ABI, at least two constructor functions (&amp;lt;code&amp;gt;ctor_complete&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ctor_base&amp;lt;/code&amp;gt;) and destructor functions (&amp;lt;code&amp;gt;dtor_complete&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;dtor_base&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;dtor_delete&amp;lt;/code&amp;gt;) are generated. The complete variants are typically used, base variants are required for base classes in the constructor/destructor, and &amp;lt;code&amp;gt;dtor_delete&amp;lt;/code&amp;gt; is used when applying delete to a class with a virtual destructor.&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/13/en&amp;diff=204</id>
		<title>Translations:Demystifying C++ - Classes/13/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/13/en&amp;diff=204"/>
		<updated>2023-10-30T10:02:33Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Importing a new version from external source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Constructors and Destructors===&lt;br /&gt;
Constructors and destructors play a pivotal role in C++ programming as they manage automatic initialization and cleanup processes for objects. Constructors are special class methods that are automatically invoked when an object is created. They&#039;re often used to define initial values for object attributes and perform other initialization tasks. Destructors are the opposite of constructors; they&#039;re invoked when an object is destroyed and are ideal for cleanup tasks like releasing memory and other resources.&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/12/en&amp;diff=203</id>
		<title>Translations:Demystifying C++ - Classes/12/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/12/en&amp;diff=203"/>
		<updated>2023-10-30T10:02:33Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Importing a new version from external source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;...&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!Derived-to-Base Cast&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
static_cast&amp;lt;Base2*&amp;gt;(derived)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;derived-&amp;gt;base2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!Static Base-To-Derived Cast&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
static_cast&amp;lt;Derived*&amp;gt;(base2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
(Derived*)((char*)base2 - offsetof(Derived, base2))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/11/en&amp;diff=202</id>
		<title>Translations:Demystifying C++ - Classes/11/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/11/en&amp;diff=202"/>
		<updated>2023-10-30T10:02:33Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Importing a new version from external source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;...&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
struct Derived {&lt;br /&gt;
  struct Base1 base1;&lt;br /&gt;
  struct Base2 base2;&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/10/en&amp;diff=201</id>
		<title>Translations:Demystifying C++ - Classes/10/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/10/en&amp;diff=201"/>
		<updated>2023-10-30T10:02:33Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Importing a new version from external source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Representation of Base Classes&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
class Derived : public Base1, public Base2 {&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/9/en&amp;diff=200</id>
		<title>Translations:Demystifying C++ - Classes/9/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/9/en&amp;diff=200"/>
		<updated>2023-10-30T10:02:33Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Importing a new version from external source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;*&#039;&#039;&#039;Derived-to-Base Casts&#039;&#039;&#039;: In assembler, such a cast corresponds to an addition with a constant value. These are relatively simple to implement in C by accessing the respective field in the derived structure. This happens implicitly in C++ in many places, such as when calling base class methods or accessing attributes.&lt;br /&gt;
*&#039;&#039;&#039;Static Base-to-Derived Casts&#039;&#039;&#039;: In assembler, such a cast corresponds to a subtraction with a constant value. This is more complex in C and requires some C casting.&lt;br /&gt;
*&#039;&#039;&#039;Dynamic Base-to-Derived Casts&#039;&#039;&#039;: These are produced with the &amp;lt;code&amp;gt;dynamic_cast&amp;lt;/code&amp;gt; keyword and are more complex in implementation since they require type checking at runtime. Dynamic casts will be discussed in the chapter on virtual classes.&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/8/en&amp;diff=199</id>
		<title>Translations:Demystifying C++ - Classes/8/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/8/en&amp;diff=199"/>
		<updated>2023-10-30T10:02:33Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Importing a new version from external source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A crucial aspect of inheritance is the casting between base classes (Base) and derived classes (Derived):&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/7/en&amp;diff=198</id>
		<title>Translations:Demystifying C++ - Classes/7/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/7/en&amp;diff=198"/>
		<updated>2023-10-30T10:02:33Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Importing a new version from external source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In C++, inheritance is a central principle that allows classes to inherit attributes and methods from base classes. However, C does not naturally support inheritance. Therefore, the C++ to C transpiler uses special techniques to simulate inheritance relationships by embedding each base class as its own field in the derived structure.&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/6/en&amp;diff=197</id>
		<title>Translations:Demystifying C++ - Classes/6/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/6/en&amp;diff=197"/>
		<updated>2023-10-30T10:02:33Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Importing a new version from external source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Inheritance===&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/5/en&amp;diff=196</id>
		<title>Translations:Demystifying C++ - Classes/5/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/5/en&amp;diff=196"/>
		<updated>2023-10-30T10:02:33Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Importing a new version from external source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;void C1_setAttr(struct C1* this, int v) {&lt;br /&gt;
  this-&amp;gt;attr = v;&lt;br /&gt;
  C1_onChangeAttr(this);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/4/en&amp;diff=195</id>
		<title>Translations:Demystifying C++ - Classes/4/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/4/en&amp;diff=195"/>
		<updated>2023-10-30T10:02:33Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Importing a new version from external source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;void C1_onChangeAttr(struct C1* this);&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/3/en&amp;diff=194</id>
		<title>Translations:Demystifying C++ - Classes/3/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/3/en&amp;diff=194"/>
		<updated>2023-10-30T10:02:33Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Importing a new version from external source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;void setAttr(int v) {&lt;br /&gt;
    attr = v;&lt;br /&gt;
    onChangeAttr();&lt;br /&gt;
  }&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
struct C1 {&lt;br /&gt;
  int attr;&lt;br /&gt;
};&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/2/en&amp;diff=193</id>
		<title>Translations:Demystifying C++ - Classes/2/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/2/en&amp;diff=193"/>
		<updated>2023-10-30T10:02:33Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Importing a new version from external source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Methods===&lt;br /&gt;
Just as the C++ compiler does, the transpiler translates classes into C structures and functions. The methods of the class are turned into functions that take a &amp;quot;this&amp;quot; pointer to the structure representing the class. When accessing attributes, the this-pointer is used automatically, and when calling other methods, it is simply passed on.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Methods&lt;br /&gt;
|&amp;lt;pre&amp;gt;&lt;br /&gt;
class C1 {&lt;br /&gt;
  int attr;&lt;br /&gt;
public:  &lt;br /&gt;
  void onChangeAttr();&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/1/en&amp;diff=192</id>
		<title>Translations:Demystifying C++ - Classes/1/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/1/en&amp;diff=192"/>
		<updated>2023-10-30T10:02:33Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Importing a new version from external source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Classes are a cornerstone of C++ programming, embodying the object-oriented paradigm, which is essential for structuring modern, complex software applications. In C++, classes encapsulate data and behavior through attributes and methods. In contrast, Assembler and C primarily rely on data structures and functions.&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/Page_display_title/en&amp;diff=191</id>
		<title>Translations:Demystifying C++ - Classes/Page display title/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B_-_Classes/Page_display_title/en&amp;diff=191"/>
		<updated>2023-10-30T10:02:33Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Importing a new version from external source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Demystifying C++ - Classes&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Demystifying_C%2B%2B/en&amp;diff=184</id>
		<title>Demystifying C++/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Demystifying_C%2B%2B/en&amp;diff=184"/>
		<updated>2023-10-30T09:59:29Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Updating to match new version of source page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;languages/&amp;gt;&lt;br /&gt;
[[File:Demystifying C++ Ghost.png|alt=|thumb|Demystifying C++]]&lt;br /&gt;
&lt;br /&gt;
[[File:Demystifying C++ Ghost.png|alt=|thumb|Demystifying C++]]&lt;br /&gt;
In the world of programming, there is a constant evolution and adaptation of languages and tools to meet the ever-growing demands of software development. While C++ is considered one of the most powerful and versatile programming languages, its complexity can often be intimidating and challenging. In this article, we take a look behind the scenes and demystify the sometimes complex C++ constructs through the lens of a C++ to C transpiler. Whether you are an experienced developer or someone just delving into the depths of C++, this article offers fascinating insights into the machinery that drives this powerful language.&lt;br /&gt;
&lt;br /&gt;
==C++ to C Transpiler==&lt;br /&gt;
A transpiler, also known as a source-to-source compiler, is a special tool that translates the source code of one programming language into the source code of another programming language. Unlike traditional compilers that translate source code into machine code, transpilers convert code from one high-level language to another.&lt;br /&gt;
&lt;br /&gt;
At emmtrix, a C++ to C transpiler is currently under development [https://www.emmtrix.com/tools/emmtrix-cpp-to-c-compiler]. It is based on the tried-and-true clang frontend, a state-of-the-art compiler frontend that is part of the broader LLVM project. A standout feature is ensuring semantic equivalence between the original C++ code and the generated C code. This means that despite the differences between the two languages, the translated code exhibits the same behavior as the original code.&lt;br /&gt;
&lt;br /&gt;
To ensure semantic equivalence, a comparison tool is used. This tool translates both the original C++ code and the generated C code into the LLVM IR (Intermediate Representation) and compares these two representations. Through this comparison, it can be ensured that the generated code not only produces the same output in test cases but also that semantically identical code is produced on every run (or an error is displayed). This approach is recognized as a method for ensuring error-free operation in both ISO26262 and DO-178C.&lt;br /&gt;
&lt;br /&gt;
The transpiler supports all C++14 language features as well as common GCC/Clang language extensions. Only exceptions are not fully supported because they cannot be replicated in C on a 1-to-1 basis. In addition to the C++ standard, the Itanium C++ ABI [https://itanium-cxx-abi.github.io/cxx-abi/abi.html] is used, which specifies the binary interface (i.e., application binary interface, ABI), for example, how classes with inheritance are implemented.&lt;br /&gt;
&lt;br /&gt;
Within the article, the transpiler is used to demystify C++ because the C output makes the implementation of the C++ constructs by the compiler easily understandable.&lt;br /&gt;
&lt;br /&gt;
==C++ Construct==&lt;br /&gt;
* [[Demystifying C++ - Classes|Classes]]&lt;br /&gt;
* [[Demystifying C++ - Virtual Classes (Polymorphism)|Virtual classes (polymorphism)]]&lt;br /&gt;
* [[Demystifying C++ - New and Delete Operators|New and delete operators]]&lt;br /&gt;
* [[Demystifying C++ - Initialization of Global Variables|Initialization of global variables]]&lt;br /&gt;
* [[Demystifying C++ - Templates|Templates]]&lt;br /&gt;
* [[Demystifying C++ - Cleanup Code|Cleanup code]]&lt;br /&gt;
* [[Demystifying C++ - Range-Based for Loops|Range-based for loops]]&lt;br /&gt;
&lt;br /&gt;
== Ideas for Future ==&lt;br /&gt;
&lt;br /&gt;
* Member function pointers&lt;br /&gt;
* Array new and delete&lt;br /&gt;
* Exceptions&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Demystifying C++|!Demystifying_C++]]&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Demystifying_C%2B%2B/ja&amp;diff=183</id>
		<title>Demystifying C++/ja</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Demystifying_C%2B%2B/ja&amp;diff=183"/>
		<updated>2023-10-30T09:59:29Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Updating to match new version of source page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;languages/&amp;gt;&lt;br /&gt;
[[File:Demystifying C++ Ghost.png|alt=|thumb|C++の解明]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-translate-fuzzy&amp;quot;&amp;gt;&lt;br /&gt;
プログラミングの世界では、ソフトウェア開発の絶えず増大する要求に応えるための言語やツールの進化と適応が続いています。C++は最も強力で多目的なプログラミング言語の一つとみなされていますが、その複雑さはしばしば威圧的であり、挑戦的です。この記事では、C++からCへのトランスパイラの視点を通して、時折複雑なC++の構造を解明して、舞台裏をのぞき見ます。あなたが経験豊富な開発者であろうと、C++の深淵に初めて足を踏み入れる人であろうと、この記事はこの強力な言語を駆動する仕組みに関する魅力的な洞察を提供します。&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==C++からCへのトランスパイラ==&lt;br /&gt;
トランスパイラは、ソースツーソースコンパイラとしても知られています。これは、あるプログラミング言語のソースコードを別のプログラミング言語のソースコードに変換する特別なツールです。ソースコードを機械コードに変換する伝統的なコンパイラとは異なり、トランスパイラは高水準の言語のコードを別の高水準の言語に変換します。&lt;br /&gt;
&lt;br /&gt;
emmtrixでは、C++からCへのトランスパイラが現在開発中です[https://www.emmtrix.com/tools/emmtrix-cpp-to-c-compiler]。これは、広範なLLVMプロジェクトの一部である最先端のコンパイラフロントエンドであるclangフロントエンドに基づいています。顕著な特徴は、元のC++コードと生成されたCコードの間の意味的な同等性を確保することです。これは、2つの言語の違いにもかかわらず、翻訳されたコードが元のコードと同じ振る舞いを示すことを意味します。&lt;br /&gt;
&lt;br /&gt;
意味的な同等性を確保するために、比較ツールが使用されます。このツールは、元のC++コードと生成されたCコードの両方をLLVM IR（中間表現）に変換し、これら2つの表現を比較します。この比較を通じて、生成されたコードがテストケースで同じ出力を生成するだけでなく、毎回の実行で意味的に同一のコードが生成されること（またはエラーが表示されること）が確保されます。このアプローチは、ISO26262およびDO-178Cの両方でエラーのない動作を確保する方法として認識されています。&lt;br /&gt;
&lt;br /&gt;
このトランスパイラは、C++14言語の全ての機能および一般的なGCC/Clang言語拡張をサポートしています。唯一の例外は、Cで1対1の基準で再現できないため、完全にはサポートされていません。C++標準に加えて、Itanium C++ ABI [https://itanium-cxx-abi.github.io/cxx-abi/abi.html]が使用されます。これは、例えば継承を持つクラスがどのように実装されるかなど、バイナリインターフェース（すなわち、アプリケーションバイナリインターフェース、ABI）を指定します。&lt;br /&gt;
&lt;br /&gt;
この記事の中で、トランスパイラはC++を解明するために使用されています。なぜなら、Cの出力は、コンパイラによるC++の構造の実装を容易に理解できるようにしているからです。&lt;br /&gt;
&lt;br /&gt;
==C++の構造==&lt;br /&gt;
* [[Demystifying C++ - Classes|クラス]]&lt;br /&gt;
* [[Demystifying C++ - Virtual Classes (Polymorphism)|仮想クラス (ポリモーフィズム)]]&lt;br /&gt;
* [[Demystifying C++ - New and Delete Operators|Newおよびdelete演算子]]&lt;br /&gt;
* [[Demystifying C++ - Initialization of Global Variables|グローバル変数の初期化]]&lt;br /&gt;
* [[Demystifying C++ - Templates|テンプレート]]&lt;br /&gt;
* [[Demystifying C++ - Cleanup Code|クリーンアップコード]]&lt;br /&gt;
* [[Demystifying C++ - Range-Based for Loops|範囲ベースのforループ]]&lt;br /&gt;
&lt;br /&gt;
== 未来のアイディア ==&lt;br /&gt;
&lt;br /&gt;
* メンバ関数ポインタ&lt;br /&gt;
* 配列のnewとdelete&lt;br /&gt;
* 例外処理&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Demystifying C++|!Demystifying_C++]]&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B/11/en&amp;diff=182</id>
		<title>Translations:Demystifying C++/11/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B/11/en&amp;diff=182"/>
		<updated>2023-10-30T09:59:28Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Importing a new version from external source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Demystifying C++ Ghost.png|alt=|thumb|Demystifying C++]]&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B/1/en&amp;diff=181</id>
		<title>Translations:Demystifying C++/1/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B/1/en&amp;diff=181"/>
		<updated>2023-10-30T09:59:28Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Importing a new version from external source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Demystifying C++ Ghost.png|alt=|thumb|Demystifying C++]]&lt;br /&gt;
In the world of programming, there is a constant evolution and adaptation of languages and tools to meet the ever-growing demands of software development. While C++ is considered one of the most powerful and versatile programming languages, its complexity can often be intimidating and challenging. In this article, we take a look behind the scenes and demystify the sometimes complex C++ constructs through the lens of a C++ to C transpiler. Whether you are an experienced developer or someone just delving into the depths of C++, this article offers fascinating insights into the machinery that drives this powerful language.&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Demystifying_C%2B%2B/en&amp;diff=152</id>
		<title>Demystifying C++/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Demystifying_C%2B%2B/en&amp;diff=152"/>
		<updated>2023-10-30T09:38:07Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Updating to match new version of source page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Demystifying C++ Ghost.png|alt=|thumb|Demystifying C++]]&lt;br /&gt;
In the world of programming, there is a constant evolution and adaptation of languages and tools to meet the ever-growing demands of software development. While C++ is considered one of the most powerful and versatile programming languages, its complexity can often be intimidating and challenging. In this article, we take a look behind the scenes and demystify the sometimes complex C++ constructs through the lens of a C++ to C transpiler. Whether you are an experienced developer or someone just delving into the depths of C++, this article offers fascinating insights into the machinery that drives this powerful language.&lt;br /&gt;
&lt;br /&gt;
==C++ to C Transpiler==&lt;br /&gt;
A transpiler, also known as a source-to-source compiler, is a special tool that translates the source code of one programming language into the source code of another programming language. Unlike traditional compilers that translate source code into machine code, transpilers convert code from one high-level language to another.&lt;br /&gt;
&lt;br /&gt;
At emmtrix, a C++ to C transpiler is currently under development [https://www.emmtrix.com/tools/emmtrix-cpp-to-c-compiler]. It is based on the tried-and-true clang frontend, a state-of-the-art compiler frontend that is part of the broader LLVM project. A standout feature is ensuring semantic equivalence between the original C++ code and the generated C code. This means that despite the differences between the two languages, the translated code exhibits the same behavior as the original code.&lt;br /&gt;
&lt;br /&gt;
To ensure semantic equivalence, a comparison tool is used. This tool translates both the original C++ code and the generated C code into the LLVM IR (Intermediate Representation) and compares these two representations. Through this comparison, it can be ensured that the generated code not only produces the same output in test cases but also that semantically identical code is produced on every run (or an error is displayed). This approach is recognized as a method for ensuring error-free operation in both ISO26262 and DO-178C.&lt;br /&gt;
&lt;br /&gt;
The transpiler supports all C++14 language features as well as common GCC/Clang language extensions. Only exceptions are not fully supported because they cannot be replicated in C on a 1-to-1 basis. In addition to the C++ standard, the Itanium C++ ABI [https://itanium-cxx-abi.github.io/cxx-abi/abi.html] is used, which specifies the binary interface (i.e., application binary interface, ABI), for example, how classes with inheritance are implemented.&lt;br /&gt;
&lt;br /&gt;
Within the article, the transpiler is used to demystify C++ because the C output makes the implementation of the C++ constructs by the compiler easily understandable.&lt;br /&gt;
&lt;br /&gt;
==C++ Construct==&lt;br /&gt;
* [[Demystifying C++ - Classes|Classes]]&lt;br /&gt;
* [[Demystifying C++ - Virtual Classes (Polymorphism)|Virtual classes (polymorphism)]]&lt;br /&gt;
* [[Demystifying C++ - New and Delete Operators|New and delete operators]]&lt;br /&gt;
* [[Demystifying C++ - Initialization of Global Variables|Initialization of global variables]]&lt;br /&gt;
* [[Demystifying C++ - Templates|Templates]]&lt;br /&gt;
* [[Demystifying C++ - Cleanup Code|Cleanup code]]&lt;br /&gt;
* [[Demystifying C++ - Range-Based for Loops|Range-based for loops]]&lt;br /&gt;
&lt;br /&gt;
== Ideas for Future ==&lt;br /&gt;
&lt;br /&gt;
* Member function pointers&lt;br /&gt;
* Array new and delete&lt;br /&gt;
* Exceptions&lt;br /&gt;
&lt;br /&gt;
[[Category:Demystifying C++|!Demystifying_C++]]&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B/10/en&amp;diff=151</id>
		<title>Translations:Demystifying C++/10/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B/10/en&amp;diff=151"/>
		<updated>2023-10-30T09:38:06Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Importing a new version from external source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Demystifying C++|!Demystifying_C++]]&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B/9/en&amp;diff=150</id>
		<title>Translations:Demystifying C++/9/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B/9/en&amp;diff=150"/>
		<updated>2023-10-30T09:38:06Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Importing a new version from external source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Member function pointers&lt;br /&gt;
* Array new and delete&lt;br /&gt;
* Exceptions&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B/8/en&amp;diff=149</id>
		<title>Translations:Demystifying C++/8/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B/8/en&amp;diff=149"/>
		<updated>2023-10-30T09:38:06Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Importing a new version from external source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Ideas for Future ==&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B/7/en&amp;diff=148</id>
		<title>Translations:Demystifying C++/7/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B/7/en&amp;diff=148"/>
		<updated>2023-10-30T09:38:06Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Importing a new version from external source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==C++ Construct==&lt;br /&gt;
* [[Demystifying C++ - Classes|Classes]]&lt;br /&gt;
* [[Demystifying C++ - Virtual Classes (Polymorphism)|Virtual classes (polymorphism)]]&lt;br /&gt;
* [[Demystifying C++ - New and Delete Operators|New and delete operators]]&lt;br /&gt;
* [[Demystifying C++ - Initialization of Global Variables|Initialization of global variables]]&lt;br /&gt;
* [[Demystifying C++ - Templates|Templates]]&lt;br /&gt;
* [[Demystifying C++ - Cleanup Code|Cleanup code]]&lt;br /&gt;
* [[Demystifying C++ - Range-Based for Loops|Range-based for loops]]&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B/6/en&amp;diff=147</id>
		<title>Translations:Demystifying C++/6/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B/6/en&amp;diff=147"/>
		<updated>2023-10-30T09:38:06Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Importing a new version from external source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Within the article, the transpiler is used to demystify C++ because the C output makes the implementation of the C++ constructs by the compiler easily understandable.&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B/5/en&amp;diff=146</id>
		<title>Translations:Demystifying C++/5/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B/5/en&amp;diff=146"/>
		<updated>2023-10-30T09:38:06Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Importing a new version from external source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The transpiler supports all C++14 language features as well as common GCC/Clang language extensions. Only exceptions are not fully supported because they cannot be replicated in C on a 1-to-1 basis. In addition to the C++ standard, the Itanium C++ ABI [https://itanium-cxx-abi.github.io/cxx-abi/abi.html] is used, which specifies the binary interface (i.e., application binary interface, ABI), for example, how classes with inheritance are implemented.&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
	<entry>
		<id>https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B/4/en&amp;diff=145</id>
		<title>Translations:Demystifying C++/4/en</title>
		<link rel="alternate" type="text/html" href="https://www.emmtrix.com/w139/index.php?title=Translations:Demystifying_C%2B%2B/4/en&amp;diff=145"/>
		<updated>2023-10-30T09:38:06Z</updated>

		<summary type="html">&lt;p&gt;FuzzyBot: Importing a new version from external source&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To ensure semantic equivalence, a comparison tool is used. This tool translates both the original C++ code and the generated C code into the LLVM IR (Intermediate Representation) and compares these two representations. Through this comparison, it can be ensured that the generated code not only produces the same output in test cases but also that semantically identical code is produced on every run (or an error is displayed). This approach is recognized as a method for ensuring error-free operation in both ISO26262 and DO-178C.&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
</feed>