why inline functions must be put in header files?

  编译中有2个过程:compile、link。先进行compile,compile中把源代码编译成目标代码(.obj),然后是link,把目标代码(obj)中的外部符号替换为真实的地址。

  inline函数的作用是减少函数调用而直接使用函数内部内容,显示是发生在compile阶段。所以如果把inline函数放在cc文件中,则compile过程中无法实现inline效果,连接器将给出 “unresolved external” 。

  事实上,inline一个函数,也意味着给该函数加上了static标签。

  参考:http://www.cnblogs.com/mydomain/archive/2013/04/06/3001859.html

why inline functions must be put in header files?的更多相关文章

  1. Inline functions

    Problems: (Page 372) There are two problems with the use of proprocessor macros in C++. The first is ...

  2. C++对象模型——Inline Functions(第四章)

    4.5 Inline Functions 以下是Point class 的一个加法运算符的可能实现内容: class Point { friend Point operator+(const Poin ...

  3. 解决Cannot find MySQL header files under /usr/include/mysql的错误

    按照下面的步骤能成功,亲测.转帖,做笔记 编译php-5.5-6的mysql支持,出现Cannot find MySQL header files under /usr/include/mysql. ...

  4. TN035: Using Multiple Resource Files and Header Files with Visual C++

    TN035: Using Multiple Resource Files and Header Files with Visual C++ This note describes how the Vi ...

  5. VC中Source Files, Header Files, Resource Files,External Dependencies的区别

    VC中Source Files, Header Files, Resource Files,External Dependencies的区别 区别: Source Files 放源文件(.c..cpp ...

  6. 编译安装php Cannot find MySQL header files under /usr/include/mysql.

    编译php-5.5-6的mysql支持,出现Cannot find MySQL header files under /usr/include/mysql. Note that the MySQL c ...

  7. Unable to find the ncurses libraries or the required header files解决

    问题: 解决方法: sudo apt-get install ncurses-dev 参考:Unable to find the ncurses libraries or the required h ...

  8. 编译安装php时提示Cannot find MySQL header files的解决方法

    php的配置文件中有一行--with-mysql=/usr/local/mysql ,安装的时候提示:configure: error: Cannot find MySQL header files ...

  9. [转载]C header files matching your running 

    原文地址:C header files matching your running kernel were not found.作者:[Opser]小默 c header files matching ...

随机推荐

  1. cxgrid中,如何根据列名或字段名取得footer值

    注意,不是根据index取得footer值cxgrdtbv1.DataController.Summary.FooterSummaryValues[0]; ------解决方案------------ ...

  2. dotTrace快速帮助你定位C#代码的性能瓶颈

    dotTrace 1.     问题描述 IIS发布的接口运行一段时间后变的很慢,重启IIS连接池后问题得到解决,但是运行一段时间后再次出现变慢的问题 2.     问题原因 程序中有读取xml文件的 ...

  3. implement min heap

    class MinHeap{ private ArrayList<Integer> arr; private int DEFAULT_LEN = 10; public MinHeap(){ ...

  4. python利用unittest测试框架组织测试用例的5种方法

    利用unittest测试框架可以编写测试用例,执行方式分两大类:利用main方法和利用testsuite,其中利用测试套件来组织测试用例可以有4种写法. 在此之前,先了解几个概念 TestCase:所 ...

  5. app流畅度测试--使用SM

    通过测量应用的帧率FPS并不能准确评价App的流畅度,FPS较低并不能代表当前App在UI上界面不流畅,而1s内VSync这个Loop运行了多少次更加能说明当前App的流畅程度. 那么我们可以直接在A ...

  6. poj3320 Jessica's Reading Problem

    Description Jessica's a very lovely girl wooed by lots of boys. Recently she has a problem. The fina ...

  7. MySql--学习成长过程

    MySql--学习成长过程 模拟测试: QQ数据库管理 一.创建数据库并添加关系和测试数据 1 ##创建QQ数据库,完成简单的测试 2 3 #创建数据库 4 DROP DATABASE IF EXIS ...

  8. P3758 [TJOI2017]可乐

    题目描述 加里敦星球的人们特别喜欢喝可乐.因而,他们的敌对星球研发出了一个可乐机器人,并且放在了加里敦星球的1号城市上.这个可乐机器人有三种行为: 停在原地,去下一个相邻的城市,自爆.它每一秒都会随机 ...

  9. 【刷题】BZOJ 1458 士兵占领

    Description 有一个M * N的棋盘,有的格子是障碍.现在你要选择一些格子来放置一些士兵,一个格子里最多可以放置一个士兵,障碍格里不能放置士兵.我们称这些士兵占领了整个棋盘当满足第i行至少放 ...

  10. 【刷题】UOJ #274 【清华集训2016】温暖会指引我们前行

    寒冬又一次肆虐了北国大地 无情的北风穿透了人们御寒的衣物 可怜虫们在冬夜中发出无助的哀嚎 "冻死宝宝了!" 这时 远处的天边出现了一位火焰之神 "我将赐予你们温暖和希望! ...