DrychronRed
Programmer
Hi! What I have is my own variable type, CVar which, for simplicity, let's say has one member int m_nData. I need to make an operator overload that returns a string version of the variable, but returning a pointer to a local variable is a no-no (of course) but I don't want/can't alloc memory for the string before I call it due to the nature of the desired operator overload. I want to be able to do this:
CVar myvar = 10 ;
char *pString = (char *)myvar ;
which I want to result with pString containing "10"
using this method:
CVar:perator (char *)
{
char strTemp[32] ;
sprintf( strTemp, "%d", m_nData ) ;
return strTemp ;
}
I know this won't work, but how else can I do it???
Thanx!!!
Cheers,
Drychron Red
CVar myvar = 10 ;
char *pString = (char *)myvar ;
which I want to result with pString containing "10"
using this method:
CVar:perator (char *)
{
char strTemp[32] ;
sprintf( strTemp, "%d", m_nData ) ;
return strTemp ;
}
I know this won't work, but how else can I do it???
Thanx!!!
Cheers,
Drychron Red