it self as holder
How can I do this?
char b = 'c';
MyChar& a = b;
A reference for char with my class
I told you the code you wrote cannot be valid
operator overloading ?
A reference is an alias, you can’t use a different type for an alias, it doesn’t make sense
Char operator?
What about pointers?
In normal scenarios, neither. You can forcé it by converting it into another type’s pointer but if you are not using inheritance it’s not usually a very good idea
assignment operator and contructor from char. CMyChar(char& ref); CMyChar& operator = (char& ref); I've made similliar project to store value type to reference type (heap stored) as part of my CVariant class that can store all value type and CString type ;p. It' lots of fun.
class Char : public Any{ private: char holder = '\0'; public: Char(); Char(char&); ~Char(); Char& operator=(char&); operator char(); Int toInt() const; Int toIntC() const; String toString() const; };
Обсуждают сегодня