1

I am having problems to define the Methode "add()". What I have learnt to define a function on another sheet until now, is basically:

type NameOfClass::function()
{
    // ...
}

So now that I try to define the function with a reference parameter (as it is a vector), I have the following declaraation in the class:

class Vector
{
    Vector add(const Vector& input) const;
    // ...
};

And I am trying to define that function with:

Vector* Vector::add(const Vector* input) const
{
    // ...
}

I am not sure if my problem is with the "input" or because I am not defining the function in the right way.

πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
David Querol
  • 31
  • 1
  • 3
  • To format code blocks, select the block and press Ctrl+K (or click the `{}` button on the toolbar). I've done it for you here, but this way you'll know for next time. – Cody Gray - on strike Jun 10 '17 at 12:07
  • 2
    You mean you define the function. Nowhere do you actually call it, you just define it after having declared it in the class definition. – Rakete1111 Jun 10 '17 at 12:08
  • https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list – Jesper Juhl Jun 10 '17 at 12:23

1 Answers1

4

Your function signatures in declaration and definition need to match exactly.

Declaration:

Vector add(const Vector& input) const;

Definition:

Vector Vector::add(const Vector& input) const
{
   //  ...
}
πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190