Jump to content
  • Advertisement
Sign in to follow this  
KodeNerd

[C++] Weird Function Definition Error

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


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

Share this post


Link to post
Share on other sites
Quote:
Original post by jyk
Quote:
Original post by KodeNerd
I tried what you said and it did not work.
Actually, you tried exactly what fpsgamer recommended, and it did work:
Quote:
Original post by fpsgamer
Either 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 KodeNerd
What did finally make it work was sending a normal reference to a Graphix object instead of a constant reference.
Recommended reading.


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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!