#include <iostream>
#include<Windows.h>
#define LENGTH 10;
#define NEWLINE '\n'
using namespace std;
int main(){
int area;
const int WIDTH=20;
area=LENGTH*WIDTH;
cout<<area<<NEWLINE;
system("pause");
}
错误在计算面积的那一行,它说“
operand of * must be a pointer
最佳答案
您不应该用 ;
终止宏定义。否则表达式扩展为:
area=10;*WIDTH;
现在这个错误是有道理的,对吧?
关于将#define 和 const 变量相乘时出现 C++ 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20906590/