// coordin.h -- strcture templates and function prototypes
// structure templates
#ifndef COORDIN_H_
#define COORDIN_H_
#include <iostream>
#include <cmath>
struct polar {
double distance;
double angle;
};
struct rect {
double x;
double y;
};
const double Pi = 3.1415927;
// function prototypes
polar rect2polar(rect xypos);
void show_polar(polar dapos);
#endif
#include <iostream>
#include "coordin.h"
int main()
{
using namespace std;
rect r_place;
polar p_place;
cout << "Enter the x and y values: ";
while (cin >> r_place.x >> r_place.y) // stick use of cin
{
p_place = rect2polar(r_place);
show_polar(p_place);
cout << "Next two numbers (q to quit): ";
}
cout << "Byebye.\n";
return 0;
}
// file2.cpp -- contains functions called in file1.cpp
#include <iostream>
#include <cmath>
#include "coordin.h"
// function declaration
polar rect2polar(rect xypos) {
polar * p_dapos = new polar;
p_dapos->distance = sqrt(xypos.x * xypos.x + xypos.y * xypos.y);
p_dapos->angle = atan2(xypos.y, xypos.x) * 180 / Pi;
return *p_dapos;
}
void show_polar(polar dapos) {
std::cout << "The distance away from Original Point: " << dapos.distance << std::endl;
std::cout << "The angle away from X axis: " << dapos.angle << " degrees" << std::endl;
}

我在把函数声明放到coordin.h内的时候程序可以运行,但是放到另外一个cpp文件中就会出现id returns 1 exit的错误,请问是什么原因导致的?如何修改?