You write a conversion operator.
Suppose you had a Date class with ints for month day and year. You could convert a Date obejct to a const char* by:
-
Date::operator const char*()
-
{
-
delete this->result;
-
this->result = new string;
-
*(this->result) + this->month;
-
*(this->result) + "/";
-
*(this->result) + this->day;
-
*(this->result) + "/";
-
*(this->result) + this->year;
-
return this->result->c_str();
-
}
-
where result is a string*.
Once you do this, you can use a Date as a const char*. Assuming, that is, that the string layout is taken into account.