Home c++ There are no instances of the overloaded pow function matching the argument...

There are no instances of the overloaded pow function matching the argument list

Author

Date

Category

I am writing a program in C++:

# include "stdafx.h"
#include "12.h"
# include & lt; iostream & gt;
# include & lt; math.h & gt;
using namespace std;
void main ()
{
  setlocale (LC_ALL, "Russian");
  double x, y, b, u;
  cout & lt; & lt; "Enter x, y \ n";
  cin & gt; & gt; x & gt; & gt; y;
  b = pow (x, 2.) * y;
  if (b & lt; = 0)
    u = tan (x);
  else if (b & gt; = 15)
     u = fabs (pow (x, exp (1.)) - y);
  else
    u = x * pow (sin, 3.) * x;
  cout & lt; & lt; "Initial data \ n";
  cout & lt; & lt; "x =" & lt; & lt; x & lt; & lt; "y =" & lt; & lt; y & lt; & lt; "\ n";
  cout & lt; & lt; "Intermediate result \ n";
  cout & lt; & lt; "b =" & lt; & lt; b & lt; & lt; "\ n";
  cout & lt; & lt; "Final result \ n";
  cout & lt; & lt; "u =" & lt; & lt; u & lt; & lt; "\ n";
}

But in the line else u = x * pow (sin, 3.) * x; gives two errors:
First:

There are no instances of the overloaded pow function that match
argument list, argument types (& lt; unknown-type & gt ;, double )

Second:

Unable to define an instance of the overloaded sin function,
which is intended to be used

How to fix them?


Answer 1, authority 100%

First, get in the habit of formatting your code. It may not help you much in this situation, but in the future you can avoid many annoying mistakes.

Second, on the line where the error is, you use the function sin as an argument to the pow function. Most likely you meant something like else u = x * pow (sin (x), 3.) * X; , but you typed it up.

And one more thing: I highly recommend enclosing the code of the if / else / for / while branches in curly braces, even if there is only one line. I myself have encountered many times situations when the second line was added to such branches, and the parentheses were not put, which led to very unpleasant errors.

Previous articleEscaping quotes in JS
Next articlejquery dropdown

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions