在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;
}
报错这样显示