Solved

function/calling this function

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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 learn how to clear a vector as well as how to detect empty vectors in C++.

759 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

19 Experts available now in Live!

Get 1:1 Help Now