I'm getting the error "circular inheritance problem encountered in 'atan'" on the last line. I'm confused since it only occurs in that line and not in main(). I only include in the cpp file and not anywhere else. Since the error is only in the class function I guess I'm doing something wrong with the class, but can't figure out what it is.
*I only threw in the main as an example of when it works. Doesn't actually serve a purpose.
//.h file
#ifndef CIRCLE_H_
#define CIRCLE_H_
class Circle {
public:
Circle(int minVertex=12);
~Circle();
private:
int pixels;
};
#endif /* CIRCLE_H_ */
// cpp file
#include <circles.h>
#include <cmath>
using namespace std;
int main(){
double pi = abs(9);
}
Circle::Circle(int minVertex = 12) {
pixels = 1150;
double pi = atan(0) *2; // problem here
}
class Circle: Circle
您有一个从自身继承的类,那怎么办?
class Circle: Circle {
Are you trying to inherit Circle
from Circle
?
Try simply
class Circle {
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.