// begin STRCLS.CPP PUBLIC DOMAIN ( part 2 of 2 )
void MyStrings::operator=(char cA)
{ char szA[2] = ""; *szA = cA; Mak(szA); }
void MyStrings::operator=(long lA)
{ char buf[32]; sprintf(buf, "%ld", lA); Mak(buf); }
void MyStrings::operator=(unsigned long luA)
{ char buf[32]; sprintf(buf, "%lu", luA); Mak(buf); }
void MyStrings::operator=(double ffA)
{
char buf[64], format[5] = "%.2f", *tokens = "0123456789";
format[2] = tokens[dP];
sprintf(buf, format, ffA);
Mak(buf);
}
void MyStrings::operator+(char cA)
{ char szA[2] = ""; *szA = cA; Add(szA); }
void MyStrings::operator+(unsigned long luA)
{ char szA[32]; sprintf(szA, "%lu", luA); Add(szA); }
void MyStrings::operator+(long lA)
{ char szA[32]; sprintf(szA, "%ld", lA); Add(szA); }
void MyStrings::operator+(double ffA)
{
char buf[64], format[5] = "%.2f", *tokens = "0123456789";
format[2] = tokens[dP];
sprintf(buf, format, ffA);
Add(buf);
}
int main(void)
{
MyStrings Name("Kurt"), Str;
Str = (short)100; cout << Str << " ";
Str = (unsigned short)200; cout << Str << " ";
Str = (int)300; cout << Str << " ";
Str = 400U; cout << Str << " ";
Str = 500L; cout << Str << " ";
Str = (unsigned long)600; cout << Str << " ";
Str = 700.5F; cout << Str << " ";
Str = -800.9F; cout << Str << endl;
Str = Name;
Str + " Kuzba ";
Str + (short)100; Str + ' ';
Str + (unsigned short)200; Str + ' ';
Str + (int)300; Str + ' ';
Str + (unsigned)400; Str + ' ';
Str + 500L; Str + ' ';
Str + 600LU; Str + ' ';
Str.Precision(4);
Str + 700.5f;
cout << Str << "\n Hit a key, " << Name << endl;
getch();
return 0;
}
// end STRCLS.CPP PUBLIC DOMAIN ( part 2 of 2 )
---
> ] Their only crime was being delicious........................
---
---------------
* Origin: *YOPS ]I[* 8.4 GIG * RA/FD/FE * Milwaukee, WI (1:154/750)
|