By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,421 Members | 1,089 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,421 IT Pros & Developers. It's quick & easy.

default parameters

P: n/a
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
Jul 22 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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
Jul 22 '05 #2

P: n/a
"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:G5**************@newsread1.dllstx09.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!
Jul 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.