B
Bill Davy
I want to be able to write (const char*)v where v is an item of type
Class::ToolTypeT where ToolTypeT is an enumeration and I've tried
everything that looks sensible. There's an ugly solution, but surely this is
possible?
I could define an operator<< but for various reasons, I really want to
convert to a 'const char*' (to embed into a string which becomes part of a
window's caption, etc).
TIA,
Bill
class Class
{
public :
typedef enum {tt_SLBTool = 0, tt_DMM1, tt_ MAX 010} ToolTypeT;
// friend operator const char*(const Class::ToolTypeT &v); //
'operator const char *' must be a non-static member
// static operator const char*(const Class::ToolTypeT &v); //
'Class:
perator const char *' must be a non-static member
};
// extern operator const char*(const Class::ToolTypeT &v); // 'operator
const char *' must be a non-static member
extern const char * Map( const Class::ToolTypeT &v); // But this is so ugly
This is what I want to write:
Class ClassObject;
..
const Class::ToolTypeT v=ClassObject.GetType();
CString str.
Str.Format("%s: version .",(const char*)v);
SetWindowText(str);
Class::ToolTypeT where ToolTypeT is an enumeration and I've tried
everything that looks sensible. There's an ugly solution, but surely this is
possible?
I could define an operator<< but for various reasons, I really want to
convert to a 'const char*' (to embed into a string which becomes part of a
window's caption, etc).
TIA,
Bill
class Class
{
public :
typedef enum {tt_SLBTool = 0, tt_DMM1, tt_ MAX 010} ToolTypeT;
// friend operator const char*(const Class::ToolTypeT &v); //
'operator const char *' must be a non-static member
// static operator const char*(const Class::ToolTypeT &v); //
'Class:
};
// extern operator const char*(const Class::ToolTypeT &v); // 'operator
const char *' must be a non-static member
extern const char * Map( const Class::ToolTypeT &v); // But this is so ugly
This is what I want to write:
Class ClassObject;
..
const Class::ToolTypeT v=ClassObject.GetType();
CString str.
Str.Format("%s: version .",(const char*)v);
SetWindowText(str);