用 #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. Tree通用的系列方法列表-treepanel

    在项目中经常会用到Tree来显示数据进行操作.今天整理出来一系列操作Tree的方法.可供项目中方便调用.不用重复写代码,快速应用,通用性很强. Tree系列方法列表如下:主要针对的是ext.net中的 ...

  2. 使用springBoot搭建REATFul风格的web demo

    1 Spring boot 核心特性 自动配置:针对常见 spring 应用程序的常见应用功能,Spring boot 自动提供相应配置 起步依赖:告诉springboot 需要什么功能,他就会自动引 ...

  3. 如何让div在整个页面中居中?

    参考必应主页的样式,在页面中放置一个表格,100%宽高,然后表格内部是一个单元格,在单元格内部放置div,使其margin为auto即可. <table style="height: ...

  4. Codeforces Round #262 (Div. 2) C

    题目: C. Present time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...

  5. scratch资源

    火柴人工作室:https://scratch.mit.edu/studios/170355/ 像素工作室:https://scratch.mit.edu/studios/3667398/ snap官网 ...

  6. #ifndef用于避免多重包含

    原因:C中,某一个重要的头文件可能被多个文件包含,如果编译的多个文件均包含了同一个头文件, 就可能存在,一个头文件被多次包含的问题. 用法:这个问题,一般用#ifndef来解决. 1.定义一个与文件名 ...

  7. C++学习笔记16,C++11中的显式的默认构造函数以及显示删除默认构造函数

    在早期的C++中.假设须要一些接受一些參数的构造函数,同一时候须要一个不接收不论什么參数的默认构造函数.就必须显示地编写空的默认构造函数.比如: //tc.h class A{ private: in ...

  8. Jar包版本查看方法

    原文:  https://blog.csdn.net/u011287511/article/details/66973559 打开Java的JAR文件我们经常可以看到文件中包含着一个META-INF目 ...

  9. spring报错:Caused by: java.lang.IllegalStateException: Cannot convert value of type for property : no matching editors or conversion strategy found

    原因分析:是因为类返回的类型跟期望的类型没有继承关系,返回的类型就SqlMapClient,它是通过实现了FactoryBean<SqlMapClient>接口的SqlMapClientF ...

  10. cocos2dx坐标系介绍

    GL坐标系 Cocos2D以OpenglES为图形库,所以它使用OpenglES坐标系.GL坐标系原点在屏幕左下角.x轴向右.y轴向上. 屏幕坐标系 苹果的Quarze2D使用的是不同的坐标系统,原点 ...