EnvelopedDevil
EnvelopedDevil

Reputation: 658

"overloaded function differs only by return type" error

I'm trying to get a hang of the base classes and pure virtual functions.

Here are the classes and headers:

IUpdatble.h

class IUpdatable
{
public:
    virtual void Update(void) = 0;
};

InputHandler.h

#include "IUpdatable.h"

class InputHandler :
public IUpdatable
{
public:
   InputHandler();
   ~InputHandler();
   virtual void Update(void);
 };

InputHandler.cpp

#include "stdafx.h"
#include "InputHandler.h"


InputHandler::InputHandler()
{
}


InputHandler::~InputHandler()
{
}

InputHandler::Update()
{
}

The compiler gives me this error at the InputHandler::Update(){}

error C2556: 'int InputHandler::Update(void)' : overloaded function differs only by return type from 'void InputHandler::Update(void)'

As far as I see both the pure virtual function is declared as void with no parameters and the overloaded function again is declared the same way.

Upvotes: 0

Views: 5058

Answers (1)

clcto
clcto

Reputation: 9648

In the C++ file (definition) you need to define the return type:

void InputHandler::Update()
^^^^
{
}

Upvotes: 5

Related Questions