C++ pass by pointer, default declaration -


if in h file, there function:

void printdictionary(dict *dic, wordtype type=all){ } 

and in corresponding cpp file, there function:

void printdictionary(dict *dic, wordtype type){ } 

will there compilation error? or correct corresponding functions?

there's error since both have function body; you've defined same function twice, breaking 1 definition rule.

declare function in header

void printdictionary(dict *dic, wordtype type=all);                                                   ^ not {} 

and define in source file did.

the default arguments should go on declaration in header, since needed call function using them. can't go on definition, definition correct is.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

xcode - Swift Playground - Files are not readable -

jboss7.x - JBoss AS 7.3 vs 7.4 and differences -