8

Any Idea why this error is coming up at compile time?

ComplexNumber.cpp:21: error: default argument given for parameter 1 of ‘void ComplexNumber::print(std::ostream&) const’
ComplexNumber.h:17: error: after previous specification in ‘void ComplexNumber::print(std::ostream&) const’

Here is my code at those certain areas:

ComplexNumber.cpp

21    void ComplexNumber::print(ostream & out = cout) const {

ComplexNumber.h

17    void print(ostream & out = cout) const;
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Pat Murray
  • 4,125
  • 7
  • 28
  • 33

1 Answers1

21

You should only specify the default parameter in the function declaration, i.e. in the header. You implementation should look something like this:

void ComplexNumber::print(ostream & out) const { ..... }
juanchopanza
  • 223,364
  • 34
  • 402
  • 480