注册 登录
编程论坛 C++教室

DEV-C++如何同时编译多个文件

tymstill 发布于 2008-03-20 15:29, 1309 次点击
DEV-C++可以建一个工程同时编译多个文件,如何操作?谢谢大虾知道!
文件一:
#ifndef COORDIN_H_
#define COORDIN_H_

struct polar
{
    double distance;   //distance from origin
    double angle;      //direction from origin
};
struct rect
{
    double x;       //horizontal distance from origin
    double y;       //vertical distance from origin
};
//prototypes
polar rect_to_polar(rect xypos);
void show_polar(polar dapos);

#endif

文件二:
#include <iostream>
#include "coordin.h"  //stucture templates,function prototypes
using namespace std;
int main()
{
    rect rplace;
    polar pplace;
   
    cout<<"Enter the x and y values: ";
    while(cin>>rplace.x>>rplace.y)      //slick use of cin
    {
        rect_to_polar(&rplace,&pplace);
        show_polar(&pplace);
        cout<<"Next two numbers(q to quit): ";
        }
        cout<<"Done.\n";
   
    system("PAUSE");
    return 0;
   
}

文件三:
#include <iostream>
#include <cmath>
#include "coordin.h"  //structure templates,function prototypes

//convert rectangular to polar coordinates
polar rect_to_polar(rect xypos)
{
     using namespace std;
     polar answer;
     
     answer.distance=
        sqrt(xypos.x*xypos.x+xypos.y*xypos.y);
     answer.angle=atan2(xypos.y,xypos.x);
     return answer;    //returns a polar structure
}

//show polar coordinates,conerting angle to degrees
void show_polar(polar dapos)
{
     using namespace std;
     const double Rad_to_deg=57.29277951;
     
     cout<<"distance = "<<pda.distance;
     cout<<", angle = "<<pda.angle *Rad_to_deg;
     cout<<" degress\n";
     }
2 回复
#2
Waiting1592008-03-20 20:43
新建 -> 工程 -> Console Application -> ……
#3
tymstill2008-03-21 09:03
能不能具体点啊
1