dimanche 29 avril 2018

return value type does not match the function type C++

I am having a problem with the error "return value type does not match the function type" for both functions test and test2 below.

I am aware I am trying to pass in my "current" pointer to something's value and this function takes a float argument.

However, for the function getTest I tried creating a float variable chkTest to compensate for that...

I am still receiving the same error.

if (type == '1') 
    { 
        float chkTest = current->test;
        return getTest(chkTest);
    }
    if (type == '2') { return getTest2(current->test2); }

My declarations for these functions in the header is:

auto getTest(float t);
auto getTest2(float t);

and my function definitions are below:

  auto TransactionType::getTest(float t)
{
    //Do Something...
};
auto TransactionType::getTest2(float t2)
{
    //Do Something...
};

If I comment out my function definitions, then this error goes away, so obviously my problems are in the function definitions (correct me if I am wrong)

Please suggest on a solution and an explanation!

Thanks.

Aucun commentaire:

Enregistrer un commentaire