小编Soa*_*nII的帖子

#define和unary'*'的无效类型参数(有'double')

刚开始编程C++,并坚持下面的代码.在Ubuntu终端上我尝试编译

g++ -o circleArea circleArea.cpp
Run Code Online (Sandbox Code Playgroud)

我收到错误:

circleArea.cpp: In function ‘int main()’:
circleArea.cpp:14:14: error: invalid type argument of unary ‘*’ (have ‘double’)
  area = PI * r * r;
              ^
Run Code Online (Sandbox Code Playgroud)

代码是:

#include <iostream>

using namespace std;

#define PI 3.14159;
#define newLine "\n";

int main(void)
{
    double r;
    double area;
    cout << "Please enter the radius : ";
    cin >> r;
    area = PI * r * r;
    cout << "Area is " << area << " unit squares" << newLine;   
} …
Run Code Online (Sandbox Code Playgroud)

c++ c-preprocessor

1
推荐指数
1
解决办法
2736
查看次数

标签 统计

c++ ×1

c-preprocessor ×1