用 #include <filename.h> 格式来引用标准库的头文件
用 #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> 格式来引用标准库的头文件的更多相关文章
- 用 #include “filename.h” 格式来引用非标准库的头文件
用 #include “filename.h” 格式来引用非标准库的头文件(编译器将 从用户的工作目录开始搜索) #include <iostream> /* run this progr ...
- 字节顺序重置及“#include <algorith.h>”相关的STL最重要的头文件提醒
这两天在写一个程序,需要将二进制文件中的数据以指定结构读入内存,说明文档中有提到大端序和小端序(Big Endian or Little Endian) 的概念,就找了一下字节顺序重置的算法,在一篇名 ...
- #include <filename.h> 和 #include“filename.h” 有什么区别
对于#include <filename.h> ,编译器从标准库路径开始搜索filename.h,对于#include “filename.h” ,编译器从用户的工作路径开始搜索filen ...
- #include<filename.h> 与 #include“filename.h”
#include<filename.h>:从标准库路径去寻找该文件,对于VC来说,应该还包括VC环境设置选项中的包含目录以及工程属性中指定的目录. #include“filename.h” ...
- Go标准库之读写文件(File)
Go标准库之读写文件(File) 创建一个空文件 package main import ( "log" "os" ) func main() { file, ...
- C++ 引用#include<math.h> 找不到动态库
问题: 使用g++ 编译C++文件报错了,无法识别abs,可是我这文件中已经添加了#include<math.h>? 于是在指令中加入-lm g++ main.cpp AStar.cpp ...
- #include、#import与@class的使用与头文件循环引用问题
#include #include <>:一般是对系统库文件的引用,编译器会去系统文件文件夹下查找. #include "xxx.h":一般是对自己定义文件的引用,编译 ...
- C和C++中include 搜索路径的一般形式以及gcc搜索头文件的路径
C和C++中include 搜索路径的一般形式 对于include 搜索的路径: C中可以通过 #include <stdio.h> 和 #include "stidio.h&q ...
- 一个C++引用库的头文件预编译陷阱
写在前面 老胡最近在工作中,有个场景需要使用一个第三方库,引用头文件,链接库,编译运行,一切都很正常,但是接下来就遇到了一个很诡异的问题,调用该库的中的一个对象方法为对象修改属性的时候,会影响到对象的 ...
随机推荐
- Googleplay从服务器检索信息时出错。[DF-DFERH-01]
googleapis.cn services.googleapis.cn 两个地址强制走代理就OK了.
- C# ASE加密解密
项目中比较常用的加密手段 /// <summary> /// ASE_128_ECB_无填充_64Base_加密函数 /// </summary> /// <param ...
- Oracle学习笔记之四,SQL语言入门
1. SQL语言概述 1.1 SQL语言特点 集合性,SQL可以的高层的数据结构上进行工作,工作时不是单条地处理记录,而对数据进行成组的处理. 统一性,操作任务主要包括:查询数据:插入.修改和删除数据 ...
- Android开发之控制摄像头拍照
如今的手机一般都会提供相机功能,有些相机的镜头甚至支持1300万以上像素,有些甚至支持独立对焦.光学变焦这些仅仅有单反才有的功能,甚至有些手机直接宣传能够拍到星星.能够说手机已经变成了专业数码相机.为 ...
- 算法练习:最小生成树 (Minimum Spanning Tree)
(注:此贴是为了回答同事提出的一个问题而匆匆写就,算法代码只求得出答案为目的,效率方面还有很大的改进空间) 最小生成树是指对于给定的带权无向图,需要生成一个总权重最小的连通图.其问题描述及算法可以详见 ...
- perl的内置函数scalar
scalar可以求数组的长度,但是,在scalar的说明里面并没有这一项. Forces EXPR to be interpreted in scalar context and returns th ...
- ise和modelsim联合仿真的一些准备
首先要在modelsim中编译xilinx的三个库,分别是unisims库,simprims库,和corelib库,其中unisims库全称为(library of united component ...
- C#二叉树简易实例
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Cons ...
- Java多线程和并发基础
第一:Java多线程面试问题 1:进程和线程之间有什么不同? 一个进程是一个独立(self contained)的运行环境,它可以被看作一个程序或者一个应用.而线程是在进程中执行的一个任务.Java运 ...
- 【转】雅典娜与宙斯的对话.(kerberos原理)
1 八月 2010 22:07:51关于Kerberos的对话(MIT)雅典娜与宙斯 雅典娜与宙斯关于地狱之门守护者的对话 Kerberos: Network Authentication Proto ...