Solved

function/calling this function

Posted on 2004-08-28
2
184 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

863 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now