Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > default parameters

Reply
Thread Tools

default parameters

 
 
Victor Bazarov
Guest
Posts: n/a
 
      08-30-2004
Ekim wrote:
> hy,


hy yourself.

> I've got a question according default parameters of functions that are
> accessed from different files:
>
> ---- logging.h ----
> void LogTrace(const char* errorLocation, const char* errorInfo = "-");
> // define default-param
> ---- end of logging.h ---
>
>
> ---- logging.cpp ----
>
> #include "Logging.h"
>
> void LogTrace(const char* errorLocation, const char* errorInfo)
> { // define function-body
> // do something
> }
> ---- end of logging.cpp ---
>
>
> and using that function from let's say 2 files in the same project like this
> :
> --- file1.cpp ---
> #include "Logging.h"
>
> and within any function call:
> LogTrace("don't use default param", "test"); // call
> function without default parameter
> LogTrace("use default param"); //
> call function with default parameter
>
> --- end of file1.cpp ---
>
>
> If I call this function as described above in just one .cpp-file, everything
> works fine. But as soon as I want to call this function from a second file
> within the same project, I get the following error-message:
> "LogTrace": redefinition of default parameter: parameter 2
>
> Can someone please tell me what I did wrong?



Could it be you somehow include the "Logging.h" file twice? Put some
double include guards in that file.

Victor
 
Reply With Quote
 
 
 
 
Ekim
Guest
Posts: n/a
 
      08-30-2004
"Victor Bazarov" <(E-Mail Removed)> wrote in message
news:G5IYc.555$(E-Mail Removed)09.us.to.ver io.net...
> Ekim wrote:
> > hy,

>
> hy yourself.
>
> > I've got a question according default parameters of functions that are
> > accessed from different files:
> >
> > ---- logging.h ----
> > void LogTrace(const char* errorLocation, const char* errorInfo = "-");
> > // define default-param
> > ---- end of logging.h ---
> >
> >
> > ---- logging.cpp ----
> >
> > #include "Logging.h"
> >
> > void LogTrace(const char* errorLocation, const char* errorInfo)
> > { // define function-body
> > // do something
> > }
> > ---- end of logging.cpp ---
> >
> >
> > and using that function from let's say 2 files in the same project like

this
> > :
> > --- file1.cpp ---
> > #include "Logging.h"
> >
> > and within any function call:
> > LogTrace("don't use default param", "test"); // call
> > function without default parameter
> > LogTrace("use default param"); //
> > call function with default parameter
> >
> > --- end of file1.cpp ---
> >
> >
> > If I call this function as described above in just one .cpp-file,

everything
> > works fine. But as soon as I want to call this function from a second

file
> > within the same project, I get the following error-message:
> > "LogTrace": redefinition of default parameter: parameter 2
> >
> > Can someone please tell me what I did wrong?

>
>
> Could it be you somehow include the "Logging.h" file twice? Put some
> double include guards in that file.
>
> Victor


yeah you're absolutely right again,
now that you mention it it's somehow clear to me - I should have made
something like #ifndef...#define...

thx once more for immediate help,
ekim!


 
Reply With Quote
 
 
 
 
Ekim
Guest
Posts: n/a
 
      08-31-2004
hy,
I've got a question according default parameters of functions that are
accessed from different files:

---- logging.h ----
void LogTrace(const char* errorLocation, const char* errorInfo = "-");
// define default-param
---- end of logging.h ---


---- logging.cpp ----

#include "Logging.h"

void LogTrace(const char* errorLocation, const char* errorInfo)
{ // define function-body
// do something
}
---- end of logging.cpp ---


and using that function from let's say 2 files in the same project like this
:
--- file1.cpp ---
#include "Logging.h"

and within any function call:
LogTrace("don't use default param", "test"); // call
function without default parameter
LogTrace("use default param"); //
call function with default parameter

--- end of file1.cpp ---


If I call this function as described above in just one .cpp-file, everything
works fine. But as soon as I want to call this function from a second file
within the same project, I get the following error-message:
"LogTrace": redefinition of default parameter: parameter 2

Can someone please tell me what I did wrong?

I appreciate any help,
ekim


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
skipping template parameters inside template parameters kito C++ 2 09-26-2010 12:04 AM
Mixing default and non-default parameters in Constructor? desktop C++ 2 06-06-2007 08:25 PM
Class Member Data and Member Function Parameters - Should Parameters Be Data Members? Jason C++ 2 05-13-2006 07:11 AM
does a "parameters"-parameter overwrite the "parameters"-object? Florian Loitsch Javascript 11 03-15-2005 03:33 PM
Servlet parameters different from the command line parameters? Jonck van der Kogel Java 2 05-26-2004 11:34 PM



Advertisments