hi , i have a function parameter that i need it to be a char and also a const char* .
can anyone help me?

void write(...) // ???
{

}
//..............................
if(somethin)
{
   write('c');
}
else
   write("string");

what you're looking for is an overloaded function

Your first function (for char's) would look like this:

void write(char c) {
...
}

Your other function (the overloaded one) should look like this:

void write(const char* c) {
...
}

The one that's needed at the time will automatically be chosen. In the case above, a parameter like 't' would cause the first to run, and one with a double quote like "t" or "test" would cause the second to run

If your function is write, and it writes to the screen, then just templatized it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.