Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

function/calling this function

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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 use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

860 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