zoukankan      html  css  js  c++  java
  • 单独编译

    自编头文件+几个文件一起编译

    • 在参考书的帮助下,成功实现第一次
      test.h
    #include<iostream>
    #ifndef TEST
    #define TEST
    struct polar{
    	double distance;
    	double angle;
    };
    struct rect{
    	double x;
    	double y;
    };
    polar rect_to_polar(rect xypos);
    void show_polar(polar dapos);
    #endif
    

    file1

    #include<iostream>
    #include"test.h"
    #include<cmath>
    #include"file2.cpp" 
    using namespace std;//要在主函数这里编译 
    int main()
    {
    	rect rplace;
    	polar pplace;
    	cout<<"enter x and y ";
    	while(cin>>rplace.x>>rplace.y)
    	{
    		pplace=rect_to_polar(rplace);
    		show_polar(pplace);
    		cout<<"next two numbers (q to quit): ";
    		
    	}
    	cout<<"Bye!
    ";
    	return 0;
     } 
    

    file2

    #include<iostream>
    #include<cmath>
    #include"test.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
    ";
    }
    
  • 相关阅读:
    Android登入界面
    安卓第4周作业
    第13周作业
    5.28上机作业
    5.22作业
    数据返回值
    登录
    安卓
    安卓第四周
    安卓第四周
  • 原文地址:https://www.cnblogs.com/2002ljy/p/12667767.html
Copyright © 2011-2022 走看看