Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

expression cant be called as a function : error

I am facing a compile time error here.

I tried to find solution to the error but cant reach a conclusion.

It says "expression cant be called as a function" when I am trying to return value using parenthesis in a user defined function.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

My code is:

template <class t1>
t1 sum(t1 a, t1 b)
{
    if (a != b)
    {
        return a + b;
    }
    else
    {
        return 3(a+b);
    }
}

>Solution :

3(a+b) means nothing for a C++ compiler. If you are trying to multiply, use 3*(a+b). If 3 is a function, change its name, you can’t use a number as a function name.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading