用 #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. php json的相关操作

    类与json <?php class userinfo { var $user_name; var $user_ip; var $user_logintime; } $u = new useri ...

  2. 基于RHCS的web双机热备集群搭建

    基于RHCS的web双机热备集群搭建 RHCS集群执行原理及功能介绍 1. 分布式集群管理器(CMAN)  Cluster Manager.简称CMAN.是一个分布式集群管理工具.它执行在集群的各个节 ...

  3. IE下JS读取xml文件示例代码

    JS读取xml文件具体步骤为:创建DOM对象.加载xml文件(仅适用于IE)附示例代码,感兴趣的朋友可以参考下,希望对大家有所帮助使用javascript脚本读取xml文件,这里暂只考虑IE浏览器st ...

  4. PCIe调试心得_DMA part2

    作者:East  FPGA那点事儿 上一章讲述了PCIe总线DMA的原理和XAPP1052存在的问题. 本章以服务器常用的4通道1000M以太网卡为例讲述如何提高DMA的效率. 1.内存重分配Wind ...

  5. 学习笔记之gethostbyaddr函数

    刚才学了gethostbyname函数,这个gethostbyaddr函数的作用是通过一个IPv4的地址来获取主机信息,并放在hostent结构体中. #include <netdb.h> ...

  6. animation几个比較好玩的属性(alternate,及animation-fill-mode)

    <!DOCTYPE html> <html> <head> <style> div { width:100px; height:100px; backg ...

  7. chrome浏览器的scrollTop问题

    使用zepto里面的scrollTop()方法是没用哒~~~ chrome浏览器: document.body.scrollTop = 一个数值 其它浏览器: document.documentEle ...

  8. C++程序文件链接

    1.什么是转换单元程序中的每个.cpp文件和它包含的所有头文件称为一个转换单元.编译器处理每个转换单元,生成二进制对象文件,用扩展名.obj来标识.链接器将对象文件组合起来,生成一个可执行文件,用扩展 ...

  9. hdoj2037 今年暑假不AC

    今年暑假不AC Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Sub ...

  10. rm: cannot remove `dir': Device or resource busy解决办法

    使用df查看系统发现: [ops@bs038 cm-5.4.0]$ df -hFilesystem Size Used Avail Use% Mounted on/dev/sda3 1.1T 200G ...