c++ - 智能感知 : identifier "[blank]" is undefined for each of the variables used in my function

标签 c++ windows visual-studio-2010 compiler-errors

我正在使用 Visual Studio。当我尝试编译我的代码时,对于“hexISOS”函数中使用的每个变量,我收到一条错误消息,提示 21“IntelliSense:标识符“[blank]”未定义”。我稍后在代码中定义了这些变量,想知道是否有人可以告诉我哪里出了问题。

我的代码是这样的:

#include <iostream>
#include <cmath>
using namespace std;

int hexISOS(double AX, AY, BX, BY, CX, CY, DX, DY)
{
    long double sol1, sol2;
    bool ans;

    sol1 = sqrt(pow((AX - CX), 2) + pow((AY - CY), 2));
    sol2 = sqrt(pow((BX - DX), 2) + pow((BY - DY), 2));

    if(sol1 == sol2)
    {
    ans = true;
    }

    else
    {
    ans = false;
    }

    cout << "\nThe distance between A and C is " << sol1 << endl;
    cout << "The distance between B and D is " << sol1 << endl;
    cout << "\nIsosceles = " << ans;

    return 0;
}

int main()
    {
    double AX, AY, BX, BY, CX, CY, DX, DY;

    cout << "AX: ";
    cin >> AX;

    cout << "\nAY: ";
    cin >> AY;

    cout << "\nBX: ";
    cin >> BX;

    cout << "\nBY: ";
    cin >> BY;

    cout << "\nCX: ";
    cin >> CX;

    cout << "\nCY: ";
    cin >> CY;

    cout << "\nDX: ";
    cin >> DX;

    cout << "\nDY: ";
    cin >> DY;

    hexISOS(AX, AY, BX, BY, CX, CY, DX, DY);

    return 0;
}

最佳答案

你可以在其中使用一次数据类型然后使用一堆变量名的东西 - 正如在你的 main 函数的第一行 - 我认为你不能在函数的参数列表中这样做。尝试这样做,看看是否有帮助:

int hexISOS(double AX, double AY, double BX, double BY, double CX, double CY, double DX,
        double DY)

编辑:另一件我认为不合法的事情是:

long double sol1, sol2;

您可能需要将其更改为如下所示:

long sol1;
double sol2;

或者类似这样的东西:

double sol1, sol2;

关于c++ - 智能感知 : identifier "[blank]" is undefined for each of the variables used in my function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10181802/

相关文章:

c++ - 不明白我是如何在结构中为变量赋值的

c++ - 将多个参数传递给函数的优雅方式

windows - Elasticsearch:如何减少主分片的数量?

javascript - Node.js 本地主机 :3000 refuses to connect

c++ - 我在 visual studio 的调用堆栈上看到的这些十六进制字符串是什么

c++ - QGraphicsView 和背景中的复杂多边形

c++ - 中级: pure virtual method called

.net - 为什么我会收到此错误 : "Domain operations cannot be started at design time?"

c++ - RegOpenKeyEx 和 RegSetValueEx 失败,但我不知道为什么

c++ - Visual C++ 2010 IDE 中的输出目录