function/calling this function

I need some help with the following:

I need to write a function called PrintLine that can be called three ways...

PrintLine("Some Text", 15);

PrintLine("Some Text");

PrintLine();

Can you help me with writing such a function?

Thanks.
LVL 1
jandhbAsked:
Who is Participating?
 
Jaime OlivaresConnect With a Mentor Software ArchitectCommented:
void PrintLine(char *text=NULL, int value=0)    // Value is the line-lenght maybe?
{
     if (text==NULL)
          // print some default text
     if (value==0)
          // take some action for this

      // print your line here
}
0
 
avizitCommented:
you need to use function overloading

the following link should be sufficient to help you write them

http://cplus.about.com/library/weekly/aa061602a.htm
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.