Please see first the code:
class BM_FONT_CALL BMfont
{
public:
BMfont();
~BMfont();
bool Load(const std::string& fontName);
void Print(float x, float y);
class BM_FONT_CALL BMstring : public std::string
{
public:
BMstring() { }
BMstring(const char* str);
BMstring& operator=(const char* str);
BMstring operator+=(const char* str);
private:
void Compile();
};
public:
BMstring text;
float scale;
_uint32 tabSize;
_uint32 textureSheet;
_uint32 backTexture;
_uint32 frontTexture;
bool enableMasking;
_uint32 base;
_uint32 lineHeight;
_uint32 pages;
_uint32 scaleW, scaleH;
_uint32 kerninfo_count;
BMkerninfo *kerninfo;
BMchar chars[MAX_CHAR];
private:
std::string _fontName;
};
How can I do BMstring
have an access to BMfont
's members, as if BMstring
will not inherit BMfont
's members? For example, if I do this:
BMfont::BMstring text;
text.scale //I don't want this
What I want to do here is, I want the BMstring::Compile()
to have an access to BMfont
with no any instance of BMfont
inside BMstring
.
Or what if I do this:
class BM_FONT_CALL BMstring : public std::string
{
std::function<void (void)> func;
public:
BMstring() { func = BMfont::Compile(); }
}
By making the Compile()
member of BMfont
.
But this won't compile. How can I achieve this?