用 #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. 软件测试自动化之- API Test

    API测试 从本质上来说,API测试是用来验证组成软件的那些单个方法的正确性,而不是测试整个系统本身. API测试也被称为单元测试(Unit Testing), 模块测试(Module Testing ...

  2. Chipscope使用

    作者:桂. 时间:2017-08-07  06:47:31 链接:http://www.cnblogs.com/xingshansi/p/7297482.html 前言 Chipscope在FPGA调 ...

  3. 怎么使用 ab.exe 测试多个url。 how to use ab.exe test many url

    from a commandline in windows: for /F %q in (list.txt) DO ab -n 1000 https://test.com/search?%q   I ...

  4. RhinoMock学习-Stub方法

    // Arrange var stub = MockRepository.GenerateStub<IDemo>(); stub.Stub(x => x.StringArgStrin ...

  5. hdoj1241 Oil Deposits

    Oil Deposits Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tota ...

  6. 关于Solr6.0中solrj使用简单例子

    solr6.0的solrJ接口有部分变化,下面列出了简单的使用实例,有需要的朋友可以参考下. package com.ailk.solr6; import java.io.IOException; i ...

  7. 续写上一篇的数组or指针操作

    C语言,同样使用if else while 这样的语法,但不同的人,就是有不同的实现方式,甚至是技巧. eg: #include <stdio.h> #include<string. ...

  8. C++ test的使用

    http://www.parasoft.com/jsp/trial_request.jsp?itemId=303 去下载,原来是个商业的测试软件,还要去购买,这个成本太大了.. http://down ...

  9. 一款基于jquery漂亮的按钮

    之前为大家分享了好多css3实现的按钮.今天给大家分享一款基于jquery漂亮的按钮.这款按钮背景下用了一张图片.当鼠标经过的时候背景用半透明div遮住.一起看下效果图: 在线预览   源码下载 实现 ...

  10. 纯css3实现图片三角形排列

    当今是个读图时代.纯大部分网页或多或少都会用到图片.特别是图片较多的网页.图片的布局和排版就非常重要了.今天要给大写带来一款纯css3实现图片三角形排列.适合一系列的图片.效果图如下: 在线预览    ...