mac代码报错
来源:8-7 标准输入输出IO重载
Homo_sapiensQ
2022-03-30
在mac上试了一下,很简单的Complex类的代码无法跑动,请问是什么原因?如何解决?
main.cpp
#include <iostream>
#include "Complex1.h"
using namespace std;
int main() {
Complex1 a(2.0, 3.0);
return 0;
}
Complex1.h
#include <iostream>
using namespace std;
class Complex1{
public:
Complex1();
Complex1(double r, double i);
virtual ~Complex1();
private:
double _r;
double _i;
};
Complex1.cpp
#include <iostream>
#include "Complex1.h"
using namespace std;
Complex1::Complex1() {
_r = 0.0;
_i = 0.0;
//cout << "Complex::Complex()" << endl;
}
Complex1::Complex1(double r, double i) {
_r = r;
_i = i;
//cout << "Complex::Complex(double r, double i)" << endl;
}
Complex1::~Complex1() {
_r = _i = 0.0;
//cout << "Complex::~Complex()" << endl;
}
报错这样显示
写回答
1回答
-
quickzhao
2022-03-30
代码貌似没啥问题。你检查下IDE中编译器的设置,感觉应该是编译器设置的问题。
042022-04-05
相似问题