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

如何使用Visual Studio 2013 将两个源代码文件和新的头文件一起编译和链接,生成一个可执行程序?

醒山 发布于 2015-11-03 17:22, 1461 次点击
如何使用Visual Studio 2013 将两个源代码文件和新的头文件一起编译和链接,生成一个可执行程序
例如
file2.ccp
#include<iostream>
#include<cmath>
#include"coordin.h"
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;
}
void show_polar(polar dapos)
{
    using namespace std;
    const double Rad_to_deg = 57.29577951;
    cout << "distance = " << dapos.distance;
    cout << ",angle = " << dapos.angle * Rad_to_deg;
    cout << " degrees\n";
}
file2.cpp
#include<iostream>
#include"coordin.h"
using namespace std;
int main()
{
    rect rplace;
    polar pplace;
    cout << "Enter the x and y value: ";
    while (cin >> rplace.x >> rplace.y)
    {
        pplace = rect_to _polar(rplace);
        show_polar(pplace);
        cout << "Next two numbers (q to quit): ";
    }
    cout << "Bye!\n";
    return 0;
}
coordin.h
#ifndef COORDIN_H_
#define COORDIN_H_
struct polar
{
    double distance;
    double angle;
};
struct rect
{
    double x;
    double y;
};
polar rect_to_polar(rect xypos);
void show_polar(polar dapos);
#endif
如何将它们一起编译,生成一个可以输入输出的可执行程序?
1 回复
#2
醒山2015-11-03 18:29
已经会弄了
1