用 #include <filename.h> 格式来引用标准库的头文件(编译器将从 标准库目录开始搜索)。

 #include <iostream>

 /* run this program using the console pauser or add your own getch, system("pause") or input loop */

 using namespace std;

 //定义结构
struct student {
char name[];
float grade;
}; //交换student类型的数据
void swap(student &x,student &y) //swap的参数为引用传递方式
{
student temp;
temp=x;
x=y;
y=temp;
} //返回student类型的引用,求优者
student& max(student &x,student &y) //swap的参数为引用传递方式
{
return (x.grade>y.grade?x:y);
} //显示student类型的数据
void show(student &x) //show的参数为引用传递方式
{
cout<<x.name<<" "<<x.grade<<endl;
}
int main(int argc, char** argv) { student a={"ZhangHua",351.5},b={"WangJun",}; //显示a和b的数据
cout<<"a:";
show(a);
cout<<"b:";
show(b);
cout<<"------------------"<<endl; //交换a和b的数据,并显示
swap(a,b);
cout<<"a:";
show(a);
cout<<"b:";
show(b);
cout<<"------------------"<<endl; //计算和显示成绩高者
student t=max(a,b);
cout<<"Max:";
show(t);
return ;
}

用 #include <filename.h> 格式来引用标准库的头文件的更多相关文章

  1. 用 #include “filename.h” 格式来引用非标准库的头文件

    用 #include “filename.h” 格式来引用非标准库的头文件(编译器将 从用户的工作目录开始搜索) #include <iostream> /* run this progr ...

  2. 字节顺序重置及“#include <algorith.h>”相关的STL最重要的头文件提醒

    这两天在写一个程序,需要将二进制文件中的数据以指定结构读入内存,说明文档中有提到大端序和小端序(Big Endian or Little Endian) 的概念,就找了一下字节顺序重置的算法,在一篇名 ...

  3. #include <filename.h> 和 #include“filename.h” 有什么区别

    对于#include <filename.h> ,编译器从标准库路径开始搜索filename.h,对于#include “filename.h” ,编译器从用户的工作路径开始搜索filen ...

  4. #include<filename.h> 与 #include“filename.h”

    #include<filename.h>:从标准库路径去寻找该文件,对于VC来说,应该还包括VC环境设置选项中的包含目录以及工程属性中指定的目录. #include“filename.h” ...

  5. Go标准库之读写文件(File)

    Go标准库之读写文件(File) 创建一个空文件 package main import ( "log" "os" ) func main() { file, ...

  6. C++ 引用#include<math.h> 找不到动态库

    问题: 使用g++ 编译C++文件报错了,无法识别abs,可是我这文件中已经添加了#include<math.h>? 于是在指令中加入-lm g++ main.cpp AStar.cpp ...

  7. #include、#import与@class的使用与头文件循环引用问题

    #include #include <>:一般是对系统库文件的引用,编译器会去系统文件文件夹下查找. #include "xxx.h":一般是对自己定义文件的引用,编译 ...

  8. C和C++中include 搜索路径的一般形式以及gcc搜索头文件的路径

    C和C++中include 搜索路径的一般形式 对于include 搜索的路径: C中可以通过 #include <stdio.h> 和 #include "stidio.h&q ...

  9. 一个C++引用库的头文件预编译陷阱

    写在前面 老胡最近在工作中,有个场景需要使用一个第三方库,引用头文件,链接库,编译运行,一切都很正常,但是接下来就遇到了一个很诡异的问题,调用该库的中的一个对象方法为对象修改属性的时候,会影响到对象的 ...

随机推荐

  1. DOA——MUSIC算法

    一.均匀圆阵(UCA, Uniform Circular Array)的MUSIC算法 假设一个半径为R的M元均匀圆阵的所有阵元均位于坐标系X-Y平面内,第k-1个阵元坐标为,第i个窄带信号波长为,来 ...

  2. 自定义相机下使用clippingNode注意事项

    调用完clippingNode->setCameraMask(myCameraMask)后,还需要clipNode->getStencil()->setCameraMask(myCa ...

  3. [Codility] CountTriangles

    A zero-indexed array A consisting of N integers is given. A triplet (P, Q, R) is triangular if it is ...

  4. Ubuntu和centos下查看包的安装路径

    安装包后,如何查看安装的具体路径? Ubuntu下: dpkg -L  <包名> CentOS下: rpm -ql   <包名> 助记: l为list的首字母. q为query ...

  5. httpwebrequest异步参考

    http://www.cnblogs.com/SanMaoSpace/archive/2011/07/27/2118133.html http://www.cnblogs.com/qianlifeng ...

  6. python(31) enumerate 的用法

    例子一: b = "abcd" kv_dict = {} pre = 1234 for i, v in enumerate(b): kv_dict['%s-%d.jpg' %(pr ...

  7. 李洪强iOS开发之-FMDB的用法

    // //  ViewController.m //  04 - FMDB的用法 // //  Created by 李洪强 on 2017/6/6. //  Copyright © 2017年 李洪 ...

  8. The power of now

    惊喜的发现,在这个短暂而又漫长的盛夏里心情开始随天气而变了(*^__^*) ...... <秘密>和<当下的力量>两者都一样,看起来费劲,不过还真的有点道理. <冰与火之 ...

  9. Gradle修改本地仓库的位置

    http://blog.csdn.net/tower888/article/details/38879955 http://blog.csdn.net/z69183787/article/detail ...

  10. 复习,关于server.xml的一点理解

    刚才在思考,我所写的一些java代码存放在了eclipse的一个workspace的目录下,这个目录下还包含我的web-project的所有html和jsp文件,以及/WEB-ROOT/WEB-INF ...