Monday

Solutions to C++ error: note: cannot convert '1' (type 'int') to type 'int&'

What is the error of the following program?

#include <iostream>
using namespace std;

template <typename T>
void insert(T& item)
{
    cout << "You cannot have the symbol \"ampersand\" "
<< "as the function parameter passed by value "
<< "to receive the integer number, "
         << "remove the symbol ampersand instead" << endl;
}

int main(int argc, char* argv[])
{
    int integer = 1;

    insert<int>(1);

    return 0;
}

Solutions:
take note that the symbol "ampersand" or "&" cannot be used as
the function parameter passed by value to receive the integer number,
the actual function caller argument, from the main() function body

error: no matching function for call to 'add<int>(int)'
note 1: candidate: 'template<class T> void add(T&)'
note 2: template argument deduction/substitution failed
note 3: cannot convert '1' (type 'int') to type 'int&'

error: note: cannot convert '1' (type 'int') to type 'int&'
Solution:
ampersand or & error at the function parameter
you cannot have the symbol "ampersand" or "&" as the function parameter passed by value,
remove the symbol ampersand or &

No comments:

If a hater attacked your age and not the goodness of you

Whether young or old, I've always been known what endures. I've known the very idea of people that were all created equal and deserv...