2

I'm working on Windows, in C++ with Visual Studio.

I have a class that has a:

enum algorithmStatus { LOADING, DETECTION, TRACKING, LOST };

In the declaration I want to use a setter and getter to change the status, something like:

void MyStatusClass::setAlgorithmStatus(algorithmStatus newStatus)
{
    //_Status = newStatus;
    //_Status = MyStatusClass::algorithmStatus::LOADING;
}

But I can't compile because I get:

Error 5 error C2511: 'void MyStatusClass::setAlgorithmStatus(MyStatusClass::algorithmStatus)' : overloaded member function not found in 'Nft_Status' c:\MyStatusClass.cpp 197

How can I do that setter correctly?

EDIT:

In header is already declarated:

    void setAlgorithmStatus(MyStatusClass::algorithmStatus newStatus);

and:

void setAlgorithmStatus(algorithmStatus newStatus);

In cpp the function is declared just i write on top.

SOLVED

The problem was i used a MyStatusClass::algorithmStatus in the constructor, you don´t need to use the MyStatusClass::, and its advisable don´t use it if you don´t need it.

4
  • 1
    Post the definition of the class. Commented Mar 19, 2012 at 9:51
  • There is something wrong in your class declaration. Probably you didn't declare setAlgorithmStatus in your class. Or you declared that function in a wrong way. The function declaration should look something like this - void setAlgorithmStatus(MyStatusClass::algorithmStatus my_variable); Commented Mar 19, 2012 at 9:52
  • The Signature of your function might me different in declaration and definition Commented Mar 19, 2012 at 9:56
  • Please note that _S is a prefixed reserved to the implementation. Commented Mar 19, 2012 at 12:06

1 Answer 1

4

The MSDN documentation for error code C2511 gives you a good list to lookout for:

identifier : overloaded member function not found in class

No version of the function is declared with the specified parameters. Possible causes:

  1. Wrong parameters passed to function.
  2. Parameters passed in wrong order.
  3. Incorrect spelling of parameter names.

Always, lookup the error codes to get help in resolving compilation errors.

Sign up to request clarification or add additional context in comments.

6 Comments

I already checked this. Visual studio detect the enum. The name its ok, in correct order.
@Piperoman: Have you declared the function correctly in your class MyStatusClass?
I think its ok, i do it on header like: void setAlgorithmStatus(MyStatusClass::algorithmStatus newStatus);
and like void setAlgorithmStatus(algorithmStatus newStatus);
@Piperoman: You need to declare the function inside the class in header file and you need to include that header file in the cpp file which uses/calls the function. The function will be defined in cpp file where you define the class, Why are you declaring the function again in cpp file where it is called?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.