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) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -