Projekt

Allgemein

Profil

Feature #763

Von Maximilian Seesslen vor etwa 3 Stunden aktualisiert

<pre><code class="cpp">
struct ConfigBase
{
char node;
int time;
};

struct ConfigBaseExpanded: ConfigBase
{
char res[0x20-sizeof(ConfigBase)];
};

struct ConfigCustom: ConfigBase
{
int color;
};

class CTest
{
protected:
ConfigBaseExpanded m_configBase;
public:
CTest()
{
printf("Base config is at %p\n", &m_configBase);
}
};

class CCustom: public CTest
{
protected:
ConfigCustom& m_config{ (ConfigCustom&)m_configBase };
public:
CCustom()
//:m_config( (ConfigCustom&)m_configBase )
{
printf("Custom config is at %p\n", &m_config);
};
};
</code></pre>

If you want to save 4 Bytes:

<pre><code class="cpp">
#define m_config (*(ConfigCustom*)&m_configBase )
</code></pre>

Zurück