# [C++] Weird Function Definition Error

This topic is 3754 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I seem to get the following error message:
C:\Users\George Gough\Documents\Limb Loss\Source\Main.cpp:24: error: no matching function for call to Graphix::MoveCamera(float, Direction) const'
C:\Users\George Gough\Documents\Limb Loss\Source\Graphix.hpp:95: note: candidates are: void Graphix::MoveCamera(float, const Direction&)


The prototype for Graphix::MoveCamera is this however:
void Graphix::MoveCamera(float amount,const Direction& direction);


Called from:
graphixObject.MoveCamera(0.5f,NORTH);

`
Why would it throw this error when it seems to be correct syntax, unless I am missing something small?

##### Share on other sites
The error is saying it cannot find "Graphix::MoveCamera(float, Direction) const"

Note the const at the end. It is looking for a const member function, which indicates you're trying to call that function on a const instance.

Either define that function to be const, or do not call it on a const instance.

const member functions

##### Share on other sites
I tried what you said and it did not work. But thank you for trying.

What did finally make it work was sending a normal reference to a Graphix object instead of a constant reference.

##### Share on other sites
Quote:
 Original post by KodeNerdI tried what you said and it did not work.
Actually, you tried exactly what fpsgamer recommended, and it did work:
Quote:
 Original post by fpsgamerEither define that function to be const, or do not call it on a const instance.
Quote:
 Original post by KodeNerdWhat did finally make it work was sending a normal reference to a Graphix object instead of a constant reference.

##### Share on other sites
Quote:
Original post by jyk
Quote:
 Original post by KodeNerdI tried what you said and it did not work.
Actually, you tried exactly what fpsgamer recommended, and it did work:
Quote:
 Original post by fpsgamerEither define that function to be const, or do not call it on a const instance.

I did not even realize that I did.

I would rate him but I seem to already have...

Quote:
Quote:
 Original post by KodeNerdWhat did finally make it work was sending a normal reference to a Graphix object instead of a constant reference.

Thank you for the reading, it helped me make sure that I was using const in the right places (there were only a few that I was not from what I read).

1. 1
Rutin
46
2. 2
3. 3
4. 4
5. 5

• 13
• 10
• 12
• 10
• 13
• ### Forum Statistics

• Total Topics
632995
• Total Posts
3009774
• ### Who's Online (See full list)

There are no registered users currently online

×