Solved

function/calling this function

Posted on 2004-08-28
2
185 Views
Last Modified: 2010-04-01
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.
0
Comment
Question by:jandhb
2 Comments
 
LVL 11

Expert Comment

by:avizit
ID: 11922746
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
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 25 total points
ID: 11922803
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

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question