【发布时间】:2020-08-10 15:16:01
【问题描述】:
看看这个:
#include <iostream> //input outut like cout, cin
#include <string> //strings
#include <cstdlib> //includes random num generators and basic c++ functions
#include <limits> //functions for min and max for data types
#include <vector>
#include <numeric> //sequences of values
#include <cmath> //math functions
#include <sstream> //string stream
#include <ctime> //time
#include <algorithm> //includes sort
#include <fstream> //alllows ofstream and ifstream for some reason? unicode vs ansi?
#include "Shape.h"
#include "Circle.h"
#include <functional> //allows you to use function poitner? <function>
#define PI 3.14159 //anywhere you see PI, it will be replaced with the number to its right
#define AREA_CIRC (radius) (PI * pow(radius, 2))
int main(){
cout << "Circle Area " << AREA_CIRC(5) << endl;
}
每当我运行这段代码时,它都会给我这个错误:
错误 C2065 'radius': 未声明的标识符 Derektut
为什么? 在宏定义中声明 int radius 没有区别
【问题讨论】:
-
去掉AREA_CIRC定义中的“int”。
-
@wychmaster 这样做会产生同样的错误
-
在发布未来的问题时,还包括标题。不知道您是否还包括了所需的
-
@skrrrt 我已经编辑它以包含我的头文件,感谢提示
标签: c++