单独编译
来源:互联网 发布:嘉拉提亚的凯旋知乎 编辑:程序博客网 时间:2024/06/11 23:47
///头文件中常包含的内容:///函数原型///使用#define或const定义的符号常量///结构声明///类声明///模板声明///内联函数///不要将函数定义或变量声明放到头文件中,可能带来麻烦///例如:若在头文件中包含一个函数定义,然后在其它两个文件///(属于同一程序)中包含该头文件,则同一个程序中将包含同一个///函数的两个定义,除非函数是内联的,否则将出错。///*********///在IDE中,不要将头文件加入到项目列表中,也不要在源代码文件///中使用#include来包含其他源代码文件。/*#include <iostream>using namespace std;int main(){ return 0;}*//// coordin.h -- structure templates and function-prototypes///structure-templates#ifndef COORDIN_H_#define COORDIN_H_struct polar{ double distance; double angle;};struct rect{ double x; double y;};///prototypes 原型:polar rect_to_polar(rect xypos);void show_polar(polar dapos);#endif // COORDIN_H_/*Enter the x and y values: 120 80distance = 144.222, angle = 33.6901 degreesNext two numbers (q to quit): 120 50distance = 130, angle = 22.6199 degreesNext two numbers (q to quit): qBye!Process returned 0 (0x0) execution time : 24.975 sPress any key to continue.*/
///file1.cpp -- example of a three-file program#include<iostream>#include"coordin.h" ///structure templates, function prototypesusing 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 { pplace = rect_to_polar(rplace); show_polar(pplace); cout << "Next two numbers (q to quit): "; } cout << "Bye!\n"; return 0;}
///file2.cpp -- contains functions called in file1.cpp#include<iostream>#include<cmath>#include"coordin.h"///convert rectangular to polar coordinatespolar 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; /// return a polar structure}///show polar coordinates, converting angle to degreesvoid show_polar (polar dapos) /// 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";}
0 0
- 单独编译
- 单独编译
- 关于qvfb单独编译
- Andriod单独编译模块
- 如何单独编译OpenCores
- android单独模块编译
- 单独编译某个工程
- 单独编译Android模块
- android单独编译
- openfire单独编译插件
- 单独编译android模块
- 单独编译gd.so
- 关于wbrtc单独编译
- 单独编译kvm模块
- c++单独编译
- Hisi单独编译kernel
- 单独编译一个ipk
- 单独编译framework
- OC 面试常见面试题:去重,排序
- uva10344
- 3-2 八皇后问题
- IO流的读写操作
- 求单链表结点的阶乘和
- 单独编译
- [sicily] 1021. Couples
- JavaScript-父子dom同时绑定两个点击事件,一个用捕获,一个用冒泡时执行顺序
- 用R语言进行数据可视化的综合指南(一)
- linux 查看文件系统类型
- NYOJ - 单调递增最长子序列
- ubuntu14.04+GPU+caffe
- Hadoop-2.7.2在Linux(centos6.5)上安装配置
- Android的线程使用来更新UI------Thread Handler Looper TimerTask等